Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More efficient cache clearing when using Redis store #23

Closed

Conversation

richardARPANET
Copy link

@richardARPANET richardARPANET commented Oct 3, 2018

  • Added namespace attribute to Memoizer.
  • Added optional namespace parameter to clear method of the Redis Store, to enable more efficient clearing.

if namespace is not None:
redis = self.dict
keys = tuple(redis.scan_iter('{0}:*'.format(namespace)))
redis.delete(*keys)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this it will loop over every single cache key and run DEL redis command. with this change it does it in a single command. i found this as i had ~300k keys in my cache and it was just running forever seemingly. now it clears in a second or so.

@richardARPANET richardARPANET force-pushed the efficient-cache-clear branch 3 times, most recently from 2272630 to 19b5bd5 Compare October 3, 2018 10:24
@richardARPANET richardARPANET force-pushed the efficient-cache-clear branch 2 times, most recently from 918c667 to dd6e88c Compare October 3, 2018 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant