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()
python 连接redis cluster的更多相关文章
- python 连接 redis cluster 集群
一. redis集群模式有多种, cluster模式只是其中的一种实现方式, 其原理请自行谷歌或者百度, 这里只举例如何使用Python操作 redis cluster 集群 二. python 连接 ...
- python连接redis,redis集群
python连接redis: import redis r = redis.Redis(host='192.168.50.181',port=6002) r.set('user_phone_14900 ...
- python连接redis哨兵集群
一.redis集群模式有多种, 哨兵模式只是其中的一种实现方式, 其原理请自行谷歌或者百度 二.python 连接 redis 哨兵集群 1. 安装redis包 pip install redis 2 ...
- python连接redis、redis字符串操作、hash操作、列表操作、其他通用操作、管道、django中使用redis
今日内容概要 python连接redis redis字符串操作 redis之hash操作 redis之列表操作 redis其他 通用操作,管道 django中使用redis 内容详细 1.python ...
- Python连接Redis连接配置
1. 测试连接: Python 2.7.8 (default, Oct 20 2014, 15:05:19) [GCC 4.9.1] on linux2 Type "help", ...
- redis基础之python连接redis(五)
前言 前面介绍了在数据库命令行直接操作redis,现在学习使用python的redis包来操作redis,本人安装的是redis==2.10.6: 系列文章 redis安装和配置 redis命令行操作 ...
- python连接redis sentinel集群
安装 python redis 客户端 pip install redis #!/usr/bin/env python # -*- coding:utf-8 -*- #!/usr/bin/env py ...
- Python连接redis时要注意的点
一.一般连接redis情况 from redis import Redis # 实例化redis对象 rdb = Redis(host='localhost', port=6379, db=0) rd ...
- python连接redis
一.首先,要下载redis pip3 install redis 二.连接redis import redis #拿到一个redis的链接 conn=redis.Redis('127.0.0.1',6 ...
随机推荐
- 【BZOJ1226】[SDOI2009] 学校食堂
题目描述 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人口味也不一定相同,但每个人的口味都可以用一个非负整数 ...
- C# string.Compare()
tring.Compare方法,用来比较2个字符串值得大小 string.Compare(str1, str2, true); 返回值: 1 : str1大于str2 0 : str1等于str2 - ...
- Jquery | 基础 | html()
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- for循环 与 for in 循环
json是js里的一种数据格式.var obj={a:15,b:8,c:12} 这是个json对象 var arr=[15,8,12]; 数组alert(obj.a); ---15al ...
- GYM 101889J(枚举、环上gcd)
答案只有n - 1种暴举即可,对于每种,gcd是一那踩雷稳了,否则看雷的分布有没有把模余占满. const int maxn = 1e5 + 5; int n, ans; char str[maxn] ...
- [github][https模式下提交记住密码]
git版本 1.7.9以后 1. 开启 git config --global credential.helper cache 2. 设置时间 git config credential.helpe ...
- vue cli 脚手架上多页面开发 支持webpack2.x
A yuri demo for webpack2 vue multiple page.我看到有一些项目多页面项目是基于webapck1.0的,我这个是在webpack2.x上布置修改. 项目地址: ...
- 【学习笔记】js中undefined和null的区别和联系
在JavaScript中存在这样两种原始类型:Null与Undefined.这两种类型常常会使JavaScript的开发人员产生疑惑,在什么时候是Null,什么时候又是Undefined? Undef ...
- uvm_test——测试用例的起点
在UVM平台验证中,所有的test cases都extends uvm_test,首先,来看源代码 //------------------------------------------------ ...
- SVN的两种存储方式FSFS和BDB比较【转】
版本库数据存储 在Subversion1.2中,版本库中存储数据有两种方式.一种是在Berkeley DB数据库中存储数据:另一种是使用普通的文件,使用自定义格式.因为Subversion的开发者称版 ...