From 3b9fc2367c5aa463af77143fde018d9a79219a33 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Jun 2015 15:57:46 +0100 Subject: 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) --- util/sql.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'util') 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; -- cgit v1.2.3