Django中配置用Redis做缓存和session

django-redis文档:

http://django-redis-chs.readthedocs.io/zh_CN/latest/#

一、在Django中配置

# Django的缓存配置
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/9",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        }
    }
}

# 配置session存储
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"

 

posted @ 2019-03-11 21:36  zhaijihai  阅读(1032)  评论(0编辑  收藏  举报