diff options
author | Matthew Wild <mwild1@gmail.com> | 2015-06-03 15:57:46 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2015-06-03 15:57:46 +0100 |
commit | 3b9fc2367c5aa463af77143fde018d9a79219a33 (patch) | |
tree | 5dbaa5689637335fae6ff647deac61e33b0784b7 /util/sql.lua | |
parent | c57a486144a2dd64276afd826af3e23e9ac2e168 (diff) | |
download | prosody-3b9fc2367c5aa463af77143fde018d9a79219a33.tar.gz prosody-3b9fc2367c5aa463af77143fde018d9a79219a33.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/sql.lua')
-rw-r--r-- | util/sql.lua | 11 |
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; |