配置 Redis 作为 Django 缓存和 Session 存储后端

一、settings.py

 1 # Django的缓存配置
 2 CACHES = {
 3     "default": {
 4         "BACKEND": "django_redis.cache.RedisCache",
 5         "LOCATION": "redis://172.16.179.130:6379/9",
 6         "OPTIONS": {
 7             "CLIENT_CLASS": "django_redis.client.DefaultClient",
 8         }
 9     }
10 }
11 
12 # 配置session存储
13 SESSION_ENGINE = "django.contrib.sessions.backends.cache"
14 SESSION_CACHE_ALIAS = "default"

猜你喜欢

转载自www.cnblogs.com/mxsf/p/10296653.html