For example, I have some cached items with same prefix, such as
'app_111111', 'app_222222', 'app_333333', ...
Can I remove such ‘app_xxxxxx’ items by any memcached commands?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Memcached does not offer this functionality out of the box so you have to build it in yourself.
The way I solve this is by defining a prefix (or namespace) in my application for groups of keys. Any key that I set in memcached has that prefix before it. Whenever I want to “delete” stuff from Memcached, I just change the prefix. And whenever I want to lookup a key in Memcached, I add that prefix to it.
In your case, you could start by setting the prefix to, say,
MyAppPrefix1, so your keys will be stored asMyAppPrefix1::app_333333,MyAppPrefix1::app_444444.Later on when you want to “delete” these entries, set your application to use
MyAppPrefix2. Then, when you try to get a key from Memcached calledapp_333333, it will look forMyAppPrefix2::app_333333and will not find it the first time around, as if it had been deleted.