RedisItemPool.py 文件源码

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

项目:python-cache 作者: python-cache 项目源码 文件源码
def save(self, item):
        """Persists a cache item immediately.

        :param item: The cache item to save.

        :return True if the item was successfully persisted. False if there was an error.

        """

        if item.expire_at != datetime.max:
            expire_seconds = (item.expire_at - datetime.utcnow()).seconds
            if expire_seconds > 0:
                return self.client.setex(self.normalize_key(item.key),
                                     cPickle.dumps(item), expire_seconds)
            else:
                return False
        else:
            return self.client.set(self.normalize_key(item.key),
                                   cPickle.dumps(item))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号