notes-------
(1)redis3.x集群模式操作需要List of all supported python versions.2.7/3.2/3.3/3.4.1+/3.5
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:
# Author: yangsq
# Email: shuqiang.yang@msxf.com
# Created: 14/03/2016
# requirement: python >=2.7
#-------------------------------------------------------------------------------
import redis
from rediscluster import StrictRedisCluster
import os, time, sys
serverip = "127.0.0.1"
startup_nodes = [{"host":serverip, "port":port} for port in xrange(7000,7006)]
def connRedisCluster():
rc = StrictRedisCluster(startup_nodes=startup_nodes)
return rc
def public_article(conn, article, user, title, link):
conn.hmset(article, {'title':title, 'publicer':user, 'link':link})
if __name__=='__main__':
print startup_nodes
rc = connRedisCluster()
public_article(rc, 'chinese_history', 'yangsq', 'war', 'http://goon')
print rc.hgetall('chinese_history')python连接redis3.x集群并做操作
最新推荐文章于 2024-04-24 15:15:12 发布
本文提供了一个使用 Python 对 Redis 集群进行操作的示例代码,包括连接配置及数据写入读取过程。通过具体实例展示了如何在 Redis 集群环境中实现数据存储。
1589

被折叠的 条评论
为什么被折叠?



