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

Clear the CacheRegion #7

Closed
sqlalchemy-bot opened this issue Jun 12, 2012 · 9 comments
Closed

Clear the CacheRegion #7

sqlalchemy-bot opened this issue Jun 12, 2012 · 9 comments
Labels

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Mark (mhall)

It would be useful if the CacheRegion had a clean() method, in addition to the delete() method, that would remove all cached values (or at least their keys) from the CacheRegion.

The use-case I have is that I cache search results and occasionally need to clear the whole cache, when an update to the search index has been performed.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

the problem with this feature is that it can't be implemented for many backends, in particular memcached, the most common backend. memcached has no way to offer a listing of keys currently cached.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

Ah but, in beaker what we did do was give the cache region a so-called "start" time. That is, when the region pulls a cached value, it not only checks the creation time of the value against the current time - expiration time, it also checks that the creation time is greater than the "start" time, which would typically be set to the timestamp at region creation time. So this doesn't clear anything out but has the effect of considering everything in the cache before region startup time to be invalid.

Mind if I update the title here to match that description ? because dogpile.cache does need this feature (I used to use it all the time).

@sqlalchemy-bot
Copy link
Author

Mark (mhall) wrote:

Ah, right. Difficult. Is there a way to access the underlying backend from a CacheRegion? That would make it possible to get the keys, where this is supported by the backend.

@sqlalchemy-bot
Copy link
Author

Mark (mhall) wrote:

So in that case, by setting the "start" time to the current time, everything created previously would become invalid? That sounds like a nice solution.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

yeah. actually we're on irc talking about it, so i think it should be simple - region.invalidate().

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

invalidate() is in [[https://bitbucket.org/zzzeek/dogpile.cache/changeset/2c97fc72ed60f1dfa2e59a8571f1207ff532e01f|2c97fc72ed60f1dfa2e59a8571f1207ff532e01f]], and I've also modified get() to use expiration/invalidation mechanics by default. We're bumped to version 0.3.0 now. Can you please field test a bit before I release ?

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

Mark (mhall) wrote:

I'll be testing and report back.

@sqlalchemy-bot
Copy link
Author

Mark (mhall) wrote:

I've been continuously running the updated version for about 3 weeks now and have seen no errors or strange behaviour from the change. As far as I am concerned, it looks stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant