Software /
code /
prosody
Changeset
6735:b553a30620b2
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)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 03 Jun 2015 15:57:46 +0100 |
parents | 6734:592f6112563e |
children | 6736:4aee55c0cc5c |
files | util/sql.lua |
diffstat | 1 files changed, 3 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/util/sql.lua Wed Jun 03 15:55:43 2015 +0100 +++ b/util/sql.lua Wed Jun 03 15:57:46 2015 +0100 @@ -283,14 +283,9 @@ 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;