mirror of
https://github.com/Hopiu/django-cachalot.git
synced 2026-05-09 05:04:55 +00:00
Commits an atomic cache after a SQL commit (not before).
This commit is contained in:
parent
ab6152dfb1
commit
be4e723b3f
1 changed files with 6 additions and 4 deletions
|
|
@ -240,13 +240,15 @@ def _patch_atomic():
|
|||
def patch_exit(original):
|
||||
@wraps(original)
|
||||
def inner(self, exc_type, exc_value, traceback):
|
||||
nested_caches = NESTED_CACHES[cachalot_settings.CACHALOT_CACHE]
|
||||
atomic_cache = nested_caches.pop()
|
||||
if exc_type is None and not connection.needs_rollback:
|
||||
atomic_cache.commit()
|
||||
needs_rollback = connection.needs_rollback
|
||||
|
||||
original(self, exc_type, exc_value, traceback)
|
||||
|
||||
nested_caches = NESTED_CACHES[cachalot_settings.CACHALOT_CACHE]
|
||||
atomic_cache = nested_caches.pop()
|
||||
if exc_type is None and not needs_rollback:
|
||||
atomic_cache.commit()
|
||||
|
||||
inner.original = original
|
||||
return inner
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue