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 ...
随机推荐
- Jquery | 基础 | .hover()
https://api.jquery.com/hover/#hover-handlerIn-handlerOut http://jquery.cuishifeng.cn/hover.html
- java多线程模拟红绿灯案例
代码Lighter.java: package pack1; /** * 灯线程 * @author Administrator * */ public class Lighter extends T ...
- bzoj2806 [Apio2012]dispatching【可并堆】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2809 保存可并堆模版代码. #include <cstdio> #include ...
- BZOJ1108(思路)
题目本质:因为只能往南和往东走所以不管怎么组合方案结果都是一样的Orz……我太菜了想不到嘤嘤嘤 #pragma comment(linker, "/STACK:1024000000,1024 ...
- (洛谷 P1429 平面最近点对(加强版) || 洛谷 P1257 || Quoit Design HDU - 1007 ) && Raid POJ - 3714
这个讲的好: https://phoenixzhao.github.io/%E6%B1%82%E6%9C%80%E8%BF%91%E5%AF%B9%E7%9A%84%E4%B8%89%E7%A7%8D ...
- python入门之数据类型之列表、元组、字典
list 格式: test_list = ["a",123,[1,"b"]] 索引: >>>print(test_list[0]) " ...
- iOS组件化开发· 什么是组件化
越来越多公司,开始了组件化,你还要等到什么时候...... 说到开发模式,我们最熟知的开发模式 MVC 或者最近比较热门的MVVM.但是我今天说的组件化的开发,其实MVC不是一类的.它其实是····· ...
- 【数据库-Azure SQL Database】SQL Server 如何将数据库备份到 Azure Storage
打开本地的 SQL Server Management Studio.首先创建 Credentials.命令如下: IF NOT EXISTS (SELECT * FROM sys.credent ...
- NBUT 1117 Kotiya's Incantation(字符输入处理)
题意: 比较两个串,有三种情况:完全相同,可见字符相同,不同.每个字符串以'-'结尾.难点在输入. 思路: 字符逐个读入,直到'-'为止,读出两串就可以直接进行判断.如果不足两串则结束.输入时需要注意 ...
- spring 中bean学习笔记
spring 中bean 一.bean的定义和应用 1. bean 形象上类似于getXX()和setXX()的一种. 2. 由于java是面向对象的,类的方法和属性在使用中需要实例化. 3. 规律: ...