Open raimannma opened 2 months ago
@jaemk Can you review this? I tried to keep the changes very minimal.
The only thing I am not sure about is whether we need to worry about cleaning up the hashmap. So if a cache is invalid, we could remove the key from the hashmap.
Also I haven't tested with Redis cache storages, could there be a problem with redis?
What's the use case of sync_writes
then?
I mean, why not to always lock by keys?
What's the use case of
sync_writes
then?
Good point.
I guess there could still be a use case where you want to lock a method independently of the key.
Also, using by_key
is a bit more expensive because it has to keep track of multiple cache instances in the hashmap.
Thanks for clarification. I'm not a maintainer, but just to give some feedbacks, I'll add my suggestions to the PR.
Applied all the refactorings :+1:
have to rewrite tests .....
Sync Writes by Key
This PR implements the
sync_writes_by_key
attribute, which works likesync_writes
, but uses an individual lock per key.This way you can call a method concurrently with different cache keys without locking the method (globally).
Related Issues: