From 2b02eec74348db846605f79d65e80370a891011c Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Sun, 19 Oct 2014 20:59:00 +0200 Subject: [PATCH] Simplification. --- cachalot/cache.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cachalot/cache.py b/cachalot/cache.py index 20f558e..2de786e 100644 --- a/cachalot/cache.py +++ b/cachalot/cache.py @@ -13,15 +13,12 @@ from .transaction import AtomicCache from .utils import _get_table_cache_key, _invalidate_tables_cache_keys -class CacheHandler(object): - def __init__(self): - self.thread_data = local() - +class CacheHandler(local): @property def atomic_caches(self): - if not hasattr(self.thread_data, 'atomic_caches'): - self.thread_data.atomic_caches = [] - return self.thread_data.atomic_caches + if not hasattr(self, '_atomic_caches'): + self._atomic_caches = [] + return self._atomic_caches def get_atomic_cache(self, cache_name, level): if cache_name not in self.atomic_caches[level]: