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],不需要写[],否则报错

猜你喜欢

转载自www.cnblogs.com/olivertian/p/10984625.html