sun*_*unw 3 django django-cache django-redis django-channels
我有一个 Django 3.1 应用程序,它使用 Redis 作为其缓存后备存储 (django-redis)。我希望使用 django-channels,它能够使用 Redis 作为通道层。
同时为缓存和 django-channels 通道层使用相同的 Redis 存储是否安全?换句话说,我希望在我的 settings.py 中包含以下内容,并且我想知道这是否可以。
import environ
env = environ.Env()
REDIS_HOST = env('REDIS_HOST', default='127.0.0.1')
REDIS_PORT = env('REDIS_PORT', default='6379')
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
"LOCATION": "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/0",
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'CONNECTION_POOL_KWARGS': {'max_connections': 30},
'IGNORE_EXCEPTIONS': True,
}
}
}
CHANNEL_LAYERS = {
"default": {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
"CONFIG": {
"hosts": [(REDIS_HOST, int(REDIS_PORT))],
},
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1096 次 |
| 最近记录: |