Reputation: 11832
I am using memcached
with pylibmc
as binaries in my Django app. Now what I want to get list of key values from cache.
Suppose I have this key value pair data in cache,
{'Key_1':[1,2,3]} {'Key_2':[4,5,6]} {'Key_3':[6,7,8]}
I can get a single record by
cache.get('Key_1')
I want to get all Key_*
data
cache.get('Key_*')
Anyone suggest a way? or is it possible?
Thanks!
Upvotes: 4
Views: 4233
Reputation: 32392
You could either use the mcdict
library and iterate through memcached like a normal dictionary or else you could look at the mcdict
source code and apply the same technique in your own code.
Upvotes: 0
Reputation: 2086
If you have dictionary than you can do something like this:
import re
dict = { 'Key_1':[1,2,3], 'Key_2':[4,5,6], 'Key_3':[6,7,8] }
r = re.compile(r"Key_\d+") // matching expression
matching_keys = filter(r.match, dict.keys())
This way you can get all matching keys and then simply iterate on those keys.
Upvotes: 2