开发者

memcached invalidation based on values

开发者 https://www.devze.com 2023-03-23 06:29 出处:网络
Is it possible to invalidate memcahced entries based on va开发者_开发百科lues. In my app, I am assigning user in different groups and I store this mapping in memcached.

Is it possible to invalidate memcahced entries based on va开发者_开发百科lues.

In my app, I am assigning user in different groups and I store this mapping in memcached.

key = userID
value = groupID

So multiple userIds map to one groupID.

When I delete a particular group then I want to remove all entries in memcache store which have value as the groupID of the deleted group. So Essentially I want to delete the entries having particular values. How do I do it.


You cannot get key's by value in memcached. What you could do though is have a key called groupID that has a comma separated userID's. If you want to see who is part of a group then you could get the key called groupID and parse out the userID's. Then if you have a key for each userID you could delete them with the parsed userID's. You could use memcached's append function too to just append the userID's to a groupID key when a new user registers for you system.


I wrote a blog post on maintaining a set a while back that may do what you're looking for.

It's essentially what mikewied is suggesting, but with more words and code samples.

0

精彩评论

暂无评论...
验证码 换一张
取 消