djangoMongoCache.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:scripts 作者: vulnersCom 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号