# redis在django中的配置 CACHES = { "default": {#default 必须加上,不然会报错 "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/5", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "CONNECTION_POOL_KWARGS": {"max_connections": 10000}, "PASSWORD": "root_joe", } }, "redis": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/2", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "CONNECTION_POOL_KWARGS": {"max_connections": 10000}, "PASSWORD": "root_joe", } } } # session的存储配置 SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 设置缓存机制为CACHES SESSION_CACHE_ALIAS = 'redis' # CACHES的redis
django session redis
最新推荐文章于 2024-08-24 07:31:56 发布