aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-06-03 15:57:46 +0100
committerMatthew Wild <mwild1@gmail.com>2015-06-03 15:57:46 +0100
commit3edc813e77f2bb5597a7f49aaf2146562313936b (patch)
tree5dbaa5689637335fae6ff647deac61e33b0784b7 /util
parent41996240ed0cc9285ecde5c68c0b5ca8bc5dcda7 (diff)
downloadprosody-3edc813e77f2bb5597a7f49aaf2146562313936b.tar.gz
prosody-3edc813e77f2bb5597a7f49aaf2146562313936b.zip
util.sql: Remove built-in engine caching. This is the wrong layer to do this, and unintentionally sharing connections could cause problems (e.g. when interleaving multiple queries and result fetching)
Diffstat (limited to 'util')
-rw-r--r--util/sql.lua11
1 files changed, 3 insertions, 8 deletions
diff --git a/util/sql.lua b/util/sql.lua
index 768dd414..5aa12f94 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -283,14 +283,9 @@ function db2uri(params)
path = params.database,
};
end
-local engine_cache = {}; -- TODO make weak valued
-function create_engine(self, params)
- local url = db2uri(params);
- if not engine_cache[url] then
- local engine = setmetatable({ url = url, params = params }, engine_mt);
- engine_cache[url] = engine;
- end
- return engine_cache[url];
+
+function create_engine(self, params, onconnect)
+ return setmetatable({ url = db2uri(params), params = params, onconnect = onconnect }, engine_mt);
end
return _M;