-
-
Notifications
You must be signed in to change notification settings - Fork 450
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 section of cache #59
Comments
[Edit: 22 July 2015 to fix inconsistency in variable names, for clarity] I was trying to figure out the same problem... I cache individual pages, for example, but I also cache "chunks" of data based on what module they belong to. And sometimes I'd like to clear the cache of any data that belongs to a certain module. Some individual caches allow you to "group" cache items like this, but for flexibility with a generic caching system, you have to be a bit more creative. In my case, I kept a second cache, whose key was a consistent module identifier (e.g. "cache.twitter"), and each value in the cache corresponded to another cache key. So I would, for example, // Save a twitter module value: // ..and repeat, adding the new key to the existing array of "twitter" keys // ..and repeat, adding the new key to the existing array of "twitter" keys Now, when you want to clear the entire "twitter" cache, you do this (in pseudo-code) $keys = $Cache->get("cache.twitter"); If you write simple functions to encapsulate this functionality, it's pretty flexible and easy to integrate. spud. On Oct 13, 2014, at 2:50 PM, tylercollier wrote:
|
Great idea. I just implemented your idea and it works great. I ended up using the term tag instead of module, because like gmail tags, I might want to tag a cache value with multiple tags. If I only ever wanted to assign a value to a particular module, I think that could be accomplished with the 'securityKey' (which only works for files and PDO drivers; I'm using the files driver) concept already present in phpfastcache. |
I have not yet tested this in the real world. I'm nervous about how long |
were you able to implement this group cache? |
@rajneeshojha: yes. I did it just like spud suggested. It was very simple. It's in my own code, not part of the phpfastcache library, so I did not do a pull request or anything. |
can you please share the code? Regards
@rajneeshojha: yes. I did it just like spud suggested. It was very simple. It's in my own code, not part of the phpfastcache library, so I did not do a pull request or anything.— |
I'd like to clear a section of my cache. Say for example that I store data by prefixing it with a namespace. Perhaps I cache some twitter data, facebook data, etc. I might store them as
twitter.myvalue1
,twitter.myvalue2
, andfacebook.myvalue1
,facebook.myvalue2
. How could I delete the cache entries for twitter? And I don't know all the names of the values. It's not necessary myvalue1/2/3/etc, I just know it starts withtwitter
.The text was updated successfully, but these errors were encountered: