Django-redis配置cache和session

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://:password@host:6379/3",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}

# Django默认session保存在cache中,所以session也是保存在redis中
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"

注意 "LOCATION": "redis://:password@host:6379/3",指定密码时,不能按照官网写的[:password],不需要写[],否则报错
posted @ 2019-06-06 14:05  olivertian  阅读(595)  评论(0编辑  收藏  举报