django-redis配置
在redis中保存cache和session
1.安装redis
pip install django-redis
2.settings中设置cache&session
# 设置django中CACHE默认的保存位置 CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", # 设置为redis所在, 以及所用库序列 "LOCATION": "redis://127.0.0.1:6379/1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", } } } # 设置session保存在cache中 SESSION_ENGINE = "django.contrib.sessions.backends.cache" SESSION_CACHE_ALIAS = "default"