Cannot invalidate specific template cache in django
def invalidate_cache_key(fragment_name, *variables):
args = md5_constructor(u':'.join([urlquote(var) for var in variables]))
cache_key = 'template.cache.%s.%s' % (fragment_name, args.hexdigest())
cache.delete(cache_key)
However, I have a situation where I need to delete all cached fragments for which a particular variable was passed. For example, delete all cached fragments about the Toyota car brand.
{% cache 100000 car_content car.brand %}
Essentially, is there a way to get all cache keys based on a specific set of criteria? I thought about changing the source of the cache, but I was wondering if there could be a better solution to this problem.
source
share