Django中使用Redis
通用方式
直接导入即可使用,在哪个文件使用就在哪个文件导入POOL实例
import redis
POOL = redis.ConnectionPool(max_connections=10, host='127.0.0.1', port=6379, decode_responses=True)
conn = redis.Redis(connection_pool=POOL)
django-redis模块
安装
pip install django-redis
settings配置文件
CACHES = {
"default"