python3 操作连接redis5.0集群

info

python 3.6
redis 5.0 cluster
centos 7.7

install

pip3 install  redis-py-cluster

demo get redis Cluster keys

from rediscluster import RedisCluster 
from redis._compat import xrange 
startup_nodes = [{"host": "172.16.0.129", "port": "7005"}] 
rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True, password='123456')
rc.set("foo", "bar") 
print(rc.get("foo")) 
list_keys = rc.keys("app_offline_msg*") 
for kye in list_keys: 
    print(kye) 

#批量设置key
for i in xrange(100):
    d = str(i)
    rc.set(d,d)
    print(rc.get(d))
    rc.incrby(d, 1)

output:

app_offline_msg_1224181518382784513
app_offline_msg_1141219459286798337
app_offline_msg_1170969231404830721
app_offline_msg_1237253025365237761
app_offline_msg_1188790203543576578
app_offline_msg_1165080615504904193
app_offline_msg_1184310738658590721
app_offline_msg_1165530388876840961
app_offline_msg_1237847397003776002
app_offline_msg_1150061722491174913
app_offline_msg_1238128445804019713
app_offline_msg_1158303431055482881
app_offline_msg_1247037518870540289
app_offline_msg_1191290475215945729
app_offline_msg_1247353611901755393
app_offline_msg_1189578220671721473
app_offline_msg_1242303462685589506
app_offline_msg_1172087496336216066
app_offline_msg_1189394020730482690
app_offline_msg_1061218902682742786
app_offline_msg_1243531224310177793
app_offline_msg_1067671227127332865
app_offline_msg_1167275077782028289
app_offline_msg_1236668192376270849
app_offline_msg_1239543302061887490
app_offline_msg_1188024860837511169
app_offline_msg_1188469694559780866
app_offline_msg_1172810205605220353
app_offline_msg_1239178770894323714
app_offline_msg_1202127231797465089
app_offline_msg_1198936165299630081
app_offline_msg_1202712812471492609
app_offline_msg_1240266807971753985
app_offline_msg_1188344386104930305
app_offline_msg_1207351269550469121
app_offline_msg_1207711808237600769
app_offline_msg_1242742417668771841
app_offline_msg_1095187697568882690
app_offline_msg_1239423766847361026
app_offline_msg_1084760738458030081
app_offline_msg_1189038197476024322
app_offline_msg_1158019816198266882
app_offline_msg_1244995629254270978
app_offline_msg_1224209439211126786
app_offline_msg_1235439911169732610
app_offline_msg_1194307772180430849
app_offline_msg_1218539502187634690
app_offline_msg_1167451168732733442
app_offline_msg_1061107157796499458
app_offline_msg_1228551494556192770
app_offline_msg_1241952401793794049
app_offline_msg_1222087041695350786
app_offline_msg_1242104132076359682
app_offline_msg_9991117
app_offline_msg_1221339464078319617
app_offline_msg_1194210628555603969
app_offline_msg_1178565590234492930
app_offline_msg_1234864907604463617
app_offline_msg_1239030787327983618

人生苦短,我用fedora

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

少陽君

谢谢老板的拿铁

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值