hincrby和hget在Redis(python)中返回True而不是实际值
为了提高性能,我使用了Redis管道,而不是单插入。请查找相同的代码段hincrby和hget在Redis(python)中返回True而不是实际值,python,redis,pipeline,Python,Redis,Pipeline,为了提高性能,我使用了Redis管道,而不是单插入。请查找相同的代码段 r = redis.Redis(connection_pool=redis_pool) r_pipeline = r.pipeline() for key in keys: r_pipeline.hincrby(key, hash, amount) r_pipeline.expire(key, Globals.Cache.ttl) return r_pipeline.execute() r_pipeline
r = redis.Redis(connection_pool=redis_pool)
r_pipeline = r.pipeline()
for key in keys:
r_pipeline.hincrby(key, hash, amount)
r_pipeline.expire(key, Globals.Cache.ttl)
return r_pipeline.execute()
r_pipeline.execute()的返回值是一个列表。基于文档,它假定递增并返回递增的值。但有时它实际上是在返回值,有时它只是返回True
我查阅了文档,并在谷歌上搜索了一下,但仍然无法找出hincrby在管道中返回True的原因
有人能帮忙吗。正确的
来自管道中的expire调用。孤立地说:
p.hincrby('key','val',1)
管道
>>>p.expire('键',120)
管道
>>>打印(p.execute())
[1L,正确]