redis python调用接口

一 安装redis client
[root@testceph ~]# yum install python-pip
安装redis-py包
[root@testceph ~]# pip install redis

二python调用程序
#!/usr/bin/env python
# -*- coding:utf8 -*-

import redis
r = redis.Redis(host='192.168.229.133',password='123456',port=6379)
r.set('foo','bar')
print(r.get('foo'))

pool = redis.ConnectionPool(host='192.168.229.133',password='123456',port=6379)

r = redis.Redis(connection_pool=pool)
r.set('name','Yu chao')
print(r.get('name'))

你可能感兴趣的:(redis)