Software / code / prosody
Comparison
util/sql.lua @ 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 |
| parent | 6734:592f6112563e |
| child | 6748:ccf4fcfc2024 |
comparison
equal
deleted
inserted
replaced
| 6734:592f6112563e | 6735:b553a30620b2 |
|---|---|
| 281 host = params.host, | 281 host = params.host, |
| 282 port = params.port, | 282 port = params.port, |
| 283 path = params.database, | 283 path = params.database, |
| 284 }; | 284 }; |
| 285 end | 285 end |
| 286 local engine_cache = {}; -- TODO make weak valued | 286 |
| 287 function create_engine(self, params) | 287 function create_engine(self, params, onconnect) |
| 288 local url = db2uri(params); | 288 return setmetatable({ url = db2uri(params), params = params, onconnect = onconnect }, engine_mt); |
| 289 if not engine_cache[url] then | |
| 290 local engine = setmetatable({ url = url, params = params }, engine_mt); | |
| 291 engine_cache[url] = engine; | |
| 292 end | |
| 293 return engine_cache[url]; | |
| 294 end | 289 end |
| 295 | 290 |
| 296 return _M; | 291 return _M; |