前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[1151]python连接 redis cluster集群

[1151]python连接 redis cluster集群

作者头像
周小董
发布2022-07-17 10:06:13
7450
发布2022-07-17 10:06:13
举报

使用pip search查看可安装的Redis模块版本

PS D:\code>pip install pip-search #安装pip-search模块
PS D:\code> pip_search redis #利用pip-search查找模块可安装的版本信息
                                                                         🐍 https://pypi.org/search/?q=redis 🐍
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Package              ┃ Version  ┃ Released     ┃ Description                                                                                                                         ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 📂 redis2            │ 2.10.6.3 │ Jan 1, 2022  │ Python client for Redis key-value store                                                                                             │
│ 📂 redis3            │ 3.5.2.3  │ Jan 1, 2022  │ Python client for Redis key-value store                                                                                             │
│ 📂 redis             │ 4.1.2 == │ Jan 27, 2022 │ Python client for Redis database and key-value store                                                                                │
│ 📂 django-redis      │ 5.2.0    │ Dec 22, 2021 │ Full featured redis cache backend for Django.                                                                                       │
│ 📂 redis-ipc         │ 0.0.1    │ Jun 27, 2021 │ A minimal multi producer single consumer IPC using redis pub/sub                                                                    │
│ 📂 bottle-redis      │ 0.2.3    │ Jun 3, 2015  │ Redis integration for Bottle.                                                                                                       │
│ 📂 rivescript-redis  │ 0.1.0    │ Feb 21, 2017 │ Redis driver for RiveScript                                                                                                         │
│ 📂 flypper-redis     │ 0.1.2    │ Jan 23, 2022 │ Feature flags, with a GUI - Redis backend                                                                                           │
│ 📂 JCoder-redis      │ 0.0.5    │ May 1, 2021  │ This Redis is a Python library based on redis.                                                                                      │
│ 📂 openid-redis      │ 1.1      │ Mar 3, 2014  │ A Redis storage backend for the python-openid package                                                                               │
│ 📂 serialized-redis  │ 0.1.5    │ Oct 12, 2014 │ A solution to have lists and dictionaries serialized using redis-py.                                                                │
│ 📂 redis-trib        │ 0.6.2    │ Nov 1, 2019  │ Redis Cluster tools in Python                                                                                                       │
│ 📂 redis_proxy       │ 0.0.2    │ Sep 11, 2013 │ a redis proxy that will seperate read and write                                                                                     │
│ 📂 redis-index       │ 0.1.11   │ Nov 8, 2019  │ Inverted Index using efficient Redis set                                                                                            │
│ 📂 redis-tornado     │ 0.2      │ Aug 28, 2012 │ Async redis client built on the Tornado IOLoop.                                                                                     │
│ 📂 sdh.redis         │ 0.1.0    │ Oct 31, 2020 │ Django redis wrapper                                                                                                                │
│ 📂 redis-collections │ 0.11.0   │ Jan 19, 2022 │ Set of basic Python collections backed by Redis.                                                                                    │
│ 📂 restful-redis     │ 0.0.2    │ Feb 24, 2018 │ Redis queues for synchronous server2server ops                                                                                      │
│ 📂 redis-persistence │ 0.0.4    │ Jan 5, 2021  │ A python module to make your Telegram bot persistent using Redis                                                                    │
│ 📂 cp-redis          │ 0.0.1    │ Jan 2, 2020  │ This is Carpool Project subpackage: cp cp-redis                                                                                     │
│ 📂 disposable-redis  │ 0.2      │ Aug 4, 2015  │ UNKNOWN                                                                                                                             │
│ 📂 stati-redis       │ 0.0.7    │ May 12, 2013 │ Python client with redis transport for GottWall statistics aggregator                                                               │
│ 📂 exec-redis        │ 0.0.10   │ Dec 2, 2021  │ Redis handler.                                                                                                                      │
│ 📂 redis_triggers    │ 0.1      │ Jul 30, 2016 │ Redis Key events that executes a function written by you such as on expiry                                                          │
│ 📂 namekox-redis     │ 0.0.26   │ Apr 29, 2021 │ namekox redis                                                                                                                       │
│ 📂 Mask-Redis        │ 1.0.0a1  │ Jun 29, 2021 │ Redis extension for Mask.                                                                                                           │
│ 📂 redis-pal         │ 0.1.4    │ Jun 15, 2021 │ Store things in Redis without worrying about types or anything, just do it!                                                         │
│ 📂 redis-schematics  │ 0.3.1    │ Feb 14, 2020 │ Redis storage backend for schematics.                                                                                               │
│ 📂 celerybeat-redis  │ 0.1.5    │ Apr 4, 2016  │ A Celery Beat Scheduler that uses Redis to store both schedule definitions and status information                                   │
│ 📂 redis-funnel      │ 0.0.1    │ Mar 26, 2019 │ A distributed funnel system based on redis, management system included.                                                             │
│ 📂 redis-cirrus      │ 2.10.5   │ Apr 20, 2016 │ Python client for Redis key-value store                                                                                             │
│ 📂 redis-sentinel    │ 1.0.1    │ Sep 11, 2020 │ Redis connection fully managed by sentinel                                                                                          │
│ 📂 redis-completion  │ 0.5.0    │ Apr 20, 2013 │ autocomplete with redis                                                                                                             │
│ 📂 redis_drs         │ 0.0.3    │ Mar 4, 2015  │ A Distributed Resource Scheduling system that uses Redis.                                                                           │
│ 📂 kinto-redis       │ 2.1.0    │ Nov 16, 2021 │ Kinto Redis                                                                                                                         │
│ 📂 redis-memslider   │ 0.1.2    │ Feb 29, 2016 │ Gradually reduce redis maxmemory.REDIS (redis.io) will block while ensuring maxmemory is honored, so when reducing it               │
│                      │          │              │ significantlyit is helpful to do so over a period of time in smaller steps if necessary. For example an AWS EC2m2.2xlarge instance  │
│                      │          │              │ takes in the vicinity of 1-5 seconds to evict 256MB of keys.                                                                        │
│ 📂 redis-relay       │ 0.0.1    │ Jul 25, 2018 │ redis relay for interprocess communication                                                                                          │
│ 📂 py-redis          │ 1.1.1    │ Dec 13, 2021 │ A convenience wrapper for the official Python redis package                                                                         │
│ 📂 joker-redis       │ 0.0.3    │ Jan 21, 2022 │ redis based utilities                                                                                                               │
│ 📂 redis_tryton      │ 0.4      │ Mar 5, 2018  │ Redis Cache for the Tryton Framework                                                                                                │
└──────────────────────┴──────────┴──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

第三方库: redis-py-cluster: 最近还在维护 rediscluster: 似乎很久没有更新了

pip install redis-py-cluster==2.1.3
or
pip install rediscluster

代码

from rediscluster import RedisCluster

# redis cluster 集群最少三主三从
startup_nodes = [
    {"host":"192.168.3.25", "port":6379},  # 主
    {"host":"192.168.3.25", "port":7001},  # 6379的从数据库
    {"host":"192.168.3.25", "port":6380},  # 主
    {"host":"192.168.3.25", "port":7002},  # 6380的从数据库
    {"host":"192.168.3.25", "port":6381},  # 主
    {"host":"192.168.3.25", "port":7003}   # 6381的从数据库
]

# 连接集群
redis_server = RedisCluster(startup_nodes=startup_nodes, decode_responses=True,password='aaa')
redis_server.set('name', 'lowman')
redis_server.get('name')

参考:http://t.zoukankan.com/lowmanisbusy-p-10991605.html https://blog.csdn.net/qq_42048263/article/details/122731953 http://www.manongjc.com/detail/15-xysgvqkubrgzlbw.html

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-07-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档