且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Redis中获得几个哈希算法的最有效的方式?

更新时间:2023-11-25 15:33:22

最有效的方式是使用管道。

The most efficient way would be using a pipeline.

假设你想要一个给定的密钥,并且已经知道所有的密钥:

Assuming you want everything for a given key and know all the keys already:

import redis

r = redis.Redis(host='localhost', port=6379, db=0)
p = r.pipeline()
for key in keys:
    p.hgetall(key)

for h in p.execute():
    print h

有关管道的更多信息,请参见: http://redis.io/topics/pipelining

More information about pipelines can be found here: http://redis.io/topics/pipelining