invalidate cache by key
See original GitHub issueWhat did I do:
@cache.invalidate("foo:client_id:{client_id}", args_map={"client_id": "client_id"})
async def bar(self, client_id):
...
What do I expect:
It works ! =)
What do I receive:
File ".../python3.9/site-packages/cashews/validation.py", line 40, in _wrap
backend.delete_match(target.format({k: str(v) if v is not None else "" for k, v in _args.items()}))
KeyError: 'client_id'
What do I suggest:
backend.delete_match(target.format(**{k: str(v) if v is not None else "" for k, v in _args.items()}))
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cache made consistent: Meta's cache invalidation solution
Cache invalidation describes the process of actively invalidating stale cache entries when data in the source of truth mutates. If a cache ......
Read more >When and How to Invalidate Cache - Lu's blog
In this post, I will talk about one way to figure out when to invalidate cache entries. I will use a specific setup...
Read more >Redis: Cache Invalidation Done Better | Ackee blog
How we reduced Redis usage during cache invalidation? ... We have all keys in one Redis database, using the GET/SET commands as expected....
Read more >InvalidateCache policy | Apigee Edge
Specifies how to construct a cache key when a Prefix element value is not specified, or to clear cache entries added by another...
Read more >Invalidating several grouped cache keys - Stack Overflow
Use a common prefix for all cache keys which are based on TicketType. Then invalidate all cache keys in a post save signal...
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
@MasterGroosha Decorating is overkill in your example. Just call
delete_match
.If you still really want to decorate something, then perhaps read https://github.com/tiangolo/fastapi/issues/2662 and https://github.com/tiangolo/fastapi/issues/1743
Your question rather belongs to discussions, than to issues.
@MasterGroosha Thanks for reporting
Yes the order order of decoration matter - and it is not an issue of cashews. It is related how decorators works, and how frameworks registers handler functions.
About
args_map
- in you case you should reverse you map:But more right way is just use right variable in key
args_map
- is a solution when you don’t want to use the key directly