diff --git a/cachalot/monkey_patch.py b/cachalot/monkey_patch.py index 8ba7b4e..35df02b 100644 --- a/cachalot/monkey_patch.py +++ b/cachalot/monkey_patch.py @@ -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) \ diff --git a/cachalot/transaction.py b/cachalot/transaction.py index 6db017b..063b81f 100644 --- a/cachalot/transaction.py +++ b/cachalot/transaction.py @@ -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)