flask-cache
flask-cache copied to clipboard
Get/delete cache entries containing/starting with a substring of the cache key
I'm trying to delete all entries in the cache store that contain (in this case start with) a substring of the cache key, but I don't see any easy way of doing this. If I understand the code correctly, I need to pass the full cache key when calling delete or delete_many. Is this correct?
I'll explain what I'm trying to do in case there is a better way: I need to clear the cache for certain users when they modify their settings. Clearing the cache with clear()
will remove the cache entries for all the users, which are some 110K, so I don't want to use that. I am generating key_prefix
with the ID of the user, the request's path, and other variables. The cache keys always start with the ID of the authenticated user.