mirror of
https://github.com/Hopiu/django-cachalot.git
synced 2026-05-10 21:53:12 +00:00
Simplification.
This commit is contained in:
parent
dbfdf3f916
commit
a504efc8a7
2 changed files with 5 additions and 9 deletions
|
|
@ -3,6 +3,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import connections
|
||||
|
||||
from .cache import cachalot_caches
|
||||
from .utils import _get_table_cache_key, _invalidate_table_cache_keys
|
||||
|
|
@ -84,4 +85,7 @@ def invalidate_all(cache_alias=None, db_alias=None):
|
|||
"""
|
||||
|
||||
for cache_alias, db_alias in _aliases_iterator(cache_alias, db_alias):
|
||||
cachalot_caches.invalidate_all(cache_alias, db_alias)
|
||||
tables = connections[db_alias].introspection.table_names()
|
||||
table_cache_keys = [_get_table_cache_key(db_alias, t) for t in tables]
|
||||
_invalidate_table_cache_keys(cachalot_caches.get_cache(cache_alias),
|
||||
table_cache_keys)
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ from threading import local
|
|||
|
||||
# TODO: Replace with caches[CACHALOT_CACHE] when we drop Django 1.6 support.
|
||||
from django.core.cache import get_cache as get_django_cache
|
||||
from django.db import connections
|
||||
|
||||
from .settings import cachalot_settings
|
||||
from .transaction import AtomicCache
|
||||
from .utils import _get_table_cache_key, _invalidate_table_cache_keys
|
||||
|
||||
|
||||
class CacheHandler(local):
|
||||
|
|
@ -43,11 +41,5 @@ class CacheHandler(local):
|
|||
for atomic_cache in atomic_caches:
|
||||
atomic_cache.commit()
|
||||
|
||||
def invalidate_all(self, cache_alias, db_alias):
|
||||
tables = connections[db_alias].introspection.table_names()
|
||||
table_cache_keys = [_get_table_cache_key(db_alias, t) for t in tables]
|
||||
_invalidate_table_cache_keys(cachalot_caches.get_cache(cache_alias),
|
||||
table_cache_keys)
|
||||
|
||||
|
||||
cachalot_caches = CacheHandler()
|
||||
|
|
|
|||
Loading…
Reference in a new issue