redis包安装
pip install redis
编写程序
# -*- coding: utf-8 -*-
from redis import Redis
handler = Redis(host='127.0.0.1')
print(handler.set('wx:accesstoken', 'gsdfgwfvwevfwgefwvef'))
print(handler.expire('wx:accesstoken', 86400))
print(handler.get('wx:accesstoken'))
print(handler.ttl('wx:accesstoken'))
输出结果如下:
imjcw@imjcwPC:~$ python redisTest.py
True
True
gsdfgwfvwevfwgefwvef
86400
如果想要知道 redis
有哪些方法,可以通过 help
方法试试。
网友评论