def get_many(self, keys, version=None):
"""
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Returns a dict mapping each key in keys to its value. If the given
key is missing, it will be missing from the response dict.
"""
out = {}
parsed_keys = {}
for key in keys:
pkey = self.make_key(key, version)
self.validate_key(pkey)
parsed_keys[pkey] = key
data = self._coll.find({'key': {'$in': parsed_keys.keys()}})
for result in data:
unencoded = base64.decodebytes(result['data'])
unpickled = pickle.loads(unencoded)
out[parsed_keys[result['key']]] = unpickled
return out
评论列表
文章目录