Watch 1 Star 2 Fork 0

youlixishi / demo-worldLGPL-2.1

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
http://demoworld.tech 中demo源代码 spread retract

Clone or download
app.py 689 Bytes
Copy Edit Web IDE Raw Blame History
youlixishi authored 2018-01-02 23:10 . no message
#coding:utf8
import redis
# 创建连接
#
config = {'host': 'localhost', 'port': 6379, 'db': 0}
#set, get 一个字符串
def set():
r = redis.Redis(**config)
r.set('name', 'zhangsan')
print(r.get('name'))
def pool_set():
pool = redis.ConnectionPool(**config)
r = redis.Redis(connection_pool=pool)
r.set('name1', 'francis') #添加
print(r.get('name1')) #获取
#带有效期的set
def set_with_expire_time():
r = redis.Redis(**config)
r.set('name', 'francis with expire time', 5)
print(r.get('name'))
#获取一个key的值
def get(key):
r = redis.Redis(**config)
print(r.get(key))
if __name__ == '__main__':
get('name')

Comment ( 0 )

Sign in for post a comment

1
https://gitee.com/youlixishi/demo-world.git
git@gitee.com:youlixishi/demo-world.git
youlixishi
demo-world
demo-world
master

Search