https://pypi.org/project/redis/
pip install redis
import redis
pool = redis.ConnectionPool( host = "localhost", port = 6379, password = ‘‘, db = 0, max_connections = 20)
from redis_db import poolimport redisimport time con = redis.Redis( connection_pool = pool) con.set("country","英国")con.set("city","伦敦")# city = con.get("city").decode("utf-8")con.expire("city",5)time.sleep(6)city = con.get("city").decode("utf-8")print(city) del con
原文地址:https://www.cnblogs.com/ericblog1992/p/11395923.html
时间: 2024-11-06 07:40:23