Skip to content

Commit

Permalink
invalidate related model key in case of many to many cached tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
selbieh committed Jul 15, 2020
1 parent 3e3d1d1 commit 14818be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions caching/invalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def wrapper(*args, **kw):


class Invalidator(object):

def invalidate_objects(self, objects, is_new_instance=False, model_cls=None):
def invalidate_objects(self, objects, is_new_instance=False, model_cls=None):
"""Invalidate all the flush lists for the given ``objects``."""
obj_keys = [k for o in objects for k in o._cache_keys()]
flush_keys = [k for o in objects for k in o._flush_keys()]
Expand All @@ -84,6 +83,7 @@ def invalidate_objects(self, objects, is_new_instance=False, model_cls=None):
if (config.CACHE_INVALIDATE_ON_CREATE == config.WHOLE_MODEL and
is_new_instance and model_cls and hasattr(model_cls, 'model_flush_key')):
flush_keys.append(model_cls.model_flush_key())
#invalidate related model key in case of many to many cached tables.
if (config.CACHE_INVALIDATE_ON_CREATE == config.WHOLE_MODEL and
not is_new_instance and model_cls and hasattr(model_cls, 'model_flush_key')):
flush_keys.append(model_cls.model_flush_key())
Expand Down

0 comments on commit 14818be

Please sign in to comment.