使用redis-py执行自定义Redis命令

4

我使用了Dynamic Redis来为Redis添加额外的功能。我能够使用redis-cli中的命令。在Python脚本中,使用redis-py可以使用这些新命令吗?

1个回答

20

找到答案了。只需扩展客户端类(StrictRedis或Redis)之一,并使用它们的execute_command方法。

redis_client = redis.StrictRedis(host, port, db)
data = redis_client.execute_command('custom redis command')

https://github.com/andymccurdy/redis-py/issues/632


1
现在StrictRedis和Redis是一样的。 - TheGuardener

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接