欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

Python 操作 Redis

程序员文章站 2022-04-18 23:20:22
...

安装 pip install redis 实例 import redis r = redis.StrictRedis(host='localhost', port=6379, db=0[, password='foo']) # 连接池 pool = redis.ConnectionPool(host='localhost', port=6379, db=0, password='foo') r = redis.Redis(connection_pool=poo

安装

pip install redis


实例

import redis


r = redis.StrictRedis(host='localhost', port=6379, db=0[, password='foo'])


# 连接池
pool = redis.ConnectionPool(host='localhost', port=6379, db=0, password='foo')
r = redis.Redis(connection_pool=pool)


r.set('foo', 'bar')
r.get('foo')


来源:https://pypi.python.org/pypi/redis

请关注

Python 操作 Redis