twinturbo/cashier — pull request #19 by amoslanka (2013-03-06 20:29:37+00:00)
Title: Cashier.expire should clear keys stored in that tag

As it currently seems to be working, if I expire a tag using cashier, after expiring all the keys associated with the tag, those keys still exist in that tag's list of keys. (I'm using Redis)

For example:

I am action caching a search page tagged with "locations" where the search string is part of the cache key. So the following would be a list of the cache keys created over a period of time:

views/localhost:3000/locations?q=1
views/localhost:3000/locations?q=2
views/localhost:3000/locations?q=3

Those three keys would be in the list under the key based on the tag "locations".

If I run `Cashier.expire "locations"`, those three view caches are correctly expired. However, if I then visit `views/localhost:3000/locations?q=4`, and then run `Cashier.keys`, I get the following output:

views/localhost:3000/locations?q=1
views/localhost:3000/locations?q=2
views/localhost:3000/locations?q=3
views/localhost:3000/locations?q=4

This is because when the tag was expired, the "locations" entry in Redis was left as is.

Is this intended? My opinion is that any key expired should be removed from the tag's list of keys. In a production environment, if there is an infinite number of queries my users would search for, then the "locations" tag's list of keys would grow infinitely as well, and it doesn't seem reasonable to expire the tag myself after running the expire method, as this is a jump into the inner workings of Cashier that my app shouldn't expect to understand.