redis install

yum install -y epel-release

yum install -y redis

vim /etc/redis.conf

修改:bind 0.0.0.0 

requirepass foobared123

systemctl restart redis

redis-cli

>>auth foobared123

 

import redis
 
pool = redis.ConnectionPool(host='192.168.1.144', port=6379,password='foobared123')
 
r = redis.Redis(connection_pool=pool)
r.set('test', 'Bar')
print r.get('test')
 
字符串操作:get(key) set(key,value)  mget(key) set(mkey,**kwargs)
hash操作:hget(name,key) hset(name,key,value)   hmget(name,key,**kwargs)
集合操作:sadd
列表操作:lpush 
posted @ 2017-10-26 18:20  howhy  阅读(280)  评论(0)    收藏  举报