I\'ve created a forum, and we\'re implementing an apc and memcache caching solution to save the database some work.
I started implementing the cache layer with keys like
I've managed to solve this by extending the memcache
class with a custom class (say ExtendedMemcache) which has a protected property which will contain a hash table of group to key values.
The ExtendedMemcache->set
method accepts 3 args ($strGroup
,$strKey
, $strValue
)
When you call set, it will store the relationship between $strGroup
, and $strKey
, in the protected property and then go on to store the $strKey
to $strValue
relationship in memcache
.
You can then add a new method to the ExtendedMemcache
class called "deleteGroup", which will, when passed a string, find that keys associated to that group, and purge each key in turn.
It would be something like this: http://pastebin.com/f566e913b I hope all that makes sense and works out for you.
PS. I suppose if you wanted to use static calls the protected property could be saved in memcache
itself under it's own key. Just a thought.
flungabunga: Your solution is very close to what I'm looking for. The only thing keeping me from doing this is having to store the relationships in memcache after each request and loading them back.
I'm not sure how much of a performance hit this would mean, but it seems a little inefficient. I will do some tests and see how it pans out. Thank you for a structured suggestion (and some code to show for it, thanks!).