Revision 1914
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
195 | 195 |
self.log_debug(cache_status+': '+strings.one_line(cur.query)) |
196 | 196 |
|
197 | 197 |
return cur |
198 |
|
|
199 |
def is_cached(self, query, params=None): |
|
200 |
return _query_lookup(query, params) in self.query_results |
|
198 | 201 |
|
199 | 202 |
connect = DbConn |
200 | 203 |
|
... | ... | |
221 | 224 |
if recover == None: recover = False |
222 | 225 |
|
223 | 226 |
def run(): return run_raw_query(db, query, params, cacheable) |
224 |
if recover: return with_savepoint(db, run) |
|
225 |
else: return run() |
|
227 |
if recover and not db.is_cached(query, params): |
|
228 |
return with_savepoint(db, run) |
|
229 |
else: return run() # don't need savepoint if cached |
|
226 | 230 |
|
227 | 231 |
##### Result retrieval |
228 | 232 |
|
Also available in: Unified diff
sql.py: DbConn: Added is_cached(). run_query(): Use new DbConn.is_cached() to avoid creating a savepoint if the query is cached.