Removes lines that became useless.

This commit is contained in:
Bertrand Bordage 2014-12-14 08:35:52 +01:00
parent b6c1dfc200
commit becfab3791
2 changed files with 4 additions and 17 deletions

View file

@ -59,14 +59,10 @@ def _get_result_or_execute_query(execute_query_func, cache_key,
now = time()
cache.set_many(dict([(k, now) for k in new_table_cache_keys]), None)
elif cache_key in data:
try:
timestamp, result = data.pop(cache_key)
except TypeError: # Occurs when None is unexpectedly found
pass
else:
table_times = data.values()
if table_times and timestamp > max(table_times):
return result
timestamp, result = data.pop(cache_key)
table_times = data.values()
if table_times and timestamp > max(table_times):
return result
result = execute_query_func()
if isinstance(result, Iterable) \

View file

@ -11,18 +11,9 @@ class AtomicCache(dict):
self.parent_cache = parent_cache
self.to_be_invalidated = set()
def get(self, k, default=None):
if k in self:
return self[k]
return self.parent_cache.get(k, default)
def set(self, k, v, timeout):
self[k] = v
def add(self, k, v, timeout):
if self.get(k) is None:
self.set(k, v, timeout)
def get_many(self, keys):
data = dict([(k, self[k]) for k in keys if k in self])
missing_keys = set(keys)