python 东哥 with open_python 连接redis cluster
#!/usr/bin/env python
# encoding: utf-8
#@author: 東哥加油!
#@file: clear_pool.py
#@time: 2018/8/28 17:06
from rediscluster import StrictRedisCluster
import datetime
import sys
def redis_cluster():
redis_nodes = [{'host':'192.168.15.6','port':6379},
{'host':'192.168.15.7','port':6379},
{'host':'192.168.15.6','port':6380},
{'host':'192.168.15.7','port':6380},
{'host':'192.168.15.8','port':6379},
{'host':'192.168.15.8','port':6380}
]
try:
redisconn = StrictRedisCluster(startup_nodes=redis_nodes)
return redisconn
except Exception:
print('Connect Error!')
sys.exit(1)
if __name__ == '__main__':
fp = open('/data/shell/sk.txt', 'ab+')
redisconn = redis_cluster()
_prize_pool = redisconn.get('_prize_pool')
n_prize = float(_prize_pool)/100
str1=str(datetime.datetime.now())+' 修改前的購物車數(shù)據(jù): '+str(n_prize)+' 元\n'
print(str1)
str2=str1.encode('utf8')
fp.write(str2)
fp.close()
總結(jié)
以上是生活随笔為你收集整理的python 东哥 with open_python 连接redis cluster的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2022年索尼有50寸高端电视吗
- 下一篇: 外墙防水多少钱一平方啊?