Invalidating cache?
See original GitHub issueFirst of all: thanks so much for all of the hard work on this! I was able to implement caching super fast.
It’d be awesome if I could somehow invalidate all of the cache keys for a given view, for example if I have caching for “Companies” in my app and I update Companies, it’d be great if I could just say:
UserKeyConstructor.invalidate_all()
or some such.
Is this possible? I noticed from key construction they are hashed, so we couldn’t do some kind of key removal based on a string/prefix…
Thanks again and have a good one!
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Cache invalidation - Wikipedia
Cache invalidation is a process in a computer system whereby entries in a cache are replaced or removed. It can be done explicitly,...
Read more >Cache invalidation overview | Cloud CDN
After an object is cached, it normally remains in the cache until it expires or is evicted to make room for new content....
Read more >What is cache invalidation? - Varnish Software
Cache invalidation refers to process during which web cache proxies declare cached content as invalid, meaning it will not longer be served as...
Read more >When and How to Invalidate Cache - Lu's blog
By "invalidate" I meant the action of updating/dropping relevant cache entries when the source of truth mutates, so no stale data is stored...
Read more >On Cache Invalidation - Why is it hard? - Yihui Xie | 谢益辉
The tricky thing is “the same thing”. How do you know that you are computing the same thing? That is all “cache invalidation”...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually think I figured something out, I can do something like this:
And invalidate all the keys like so:
and fire this off with signals:
The solution by @ckcollab here is better than the official documentations solution – this actually removes the cache entries instead of adding new ones. The solution in the official documentation will eventually fill the cache with redundant previously cached data.