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())+' 修改前的购物车数据: '+str(n_prize)+' 元\n'

print(str1)

str2=str1.encode('utf8')

fp.write(str2)

fp.close()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值