python3.x操作redis
来源:互联网 发布:javascript 控制height 编辑:程序博客网 时间:2024/06/05 22:57
python3.x操作redis
1、安转redis;pip install redis;
2、redis文档:http://redis-py.readthedocs.io/en/latest/
下面为redis库的接口封装:
import redisimport configparserCONFIG = configparser.ConfigParser()CONFIG.read("config/system.ini")redis_host = CONFIG.get("redis", "REDIS_HOST")redis_port = CONFIG.get("redis","REDIS_PORT")redis_db=CONFIG.get("redis","REDIS_DB")redis_pwd=CONFIG.get("redis","REDIS_PASSWORD")redisConnect = redis.Redis(redis_host,redis_port,redis_db,redis_pwd)class RedisTool:@staticmethoddef hexists(name,key):return redisConnect.hexists(name,key)@staticmethoddef hget(name, key):return redisConnect.hget(name, key)@staticmethoddef getset(name, value):return redisConnect.getset(name, value)@staticmethoddef hdel(name, *keys):return redisConnect.hdel(name, *keys)@staticmethoddef hgetall(name):return redisConnect.hgetall(name)@staticmethoddef hkeys(name):return redisConnect.hkeys(name)@staticmethoddef hlen(name):return redisConnect.hlen(name)#Set key to value within hash name Returns 1 if HSET created a new field, otherwise 0@staticmethoddef hset(name, key, value):return redisConnect.hset(name, key, value)@staticmethoddef setex(name, time, value):return redisConnect.setex(name, time, value)@staticmethoddef get(name):return redisConnect.get(name)@staticmethoddef exists(name):return redisConnect.exists(name)@staticmethoddef set(name, value):return redisConnect.set(name, value)
0 0
- python3.x操作redis
- [bigdata-55] python3 操作redis
- python3.X操作mysql数据库
- Python3.x opencv操作中文文件
- Python3.x
- Python3.x
- Python3.x那些事儿:[27]更多List操作
- 基于python3.x,使用Tornado中的torndb模块操作数据库
- python2.x ~ python3.x
- centos6.X升级python3.X
- python3.X的变化
- Python3.X学习笔记
- Python3.x区别
- python3.x学习小记
- python3.x Linux安装
- Python3.x urllib
- Python3.X 下载图片
- Python3.X 抓取网络资源
- lesson 5 操作系统
- Zookeeper 集群
- 关于mybatis传递string字符串判断
- js基本使用
- picasso-强大的Android图片下载缓存库
- python3.x操作redis
- 与技术无关-电视剧《小别离》经典台词
- 代码笔记 | 哥德巴赫猜想的计算机验证
- 使用Nginx+FFMPEG搭建HLS直播转码服务器
- POJ 3139 Balancing the Scale
- Activity中心打开动画效果工具类
- 关于Mybatis中动态查询表和表中的列
- python的http代理,对请求的头文件中的json数据进行比对-------(2)
- 代码笔记 | BP神经网络的C语言代码