[英]Django Redis set max connections
I'm using Django and having issues exceeding my max number of redis connections. 我正在使用Django,遇到的问题超出了我的Redis连接的最大数量。 The library I'm using is:
我正在使用的库是:
https://github.com/sebleier/django-redis-cache https://github.com/sebleier/django-redis-cache
Here is my settings.py file: 这是我的settings.py文件:
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': "pub-redis-11905.us-east-1-3.1.ec2.garantiadata.com:11905",
'OPTIONS': {
'DB' : 0,
'PASSWORD': "*****",
'PARSER_CLASS': 'redis.connection.HiredisParser'
},
},
}
Then i another file, I do some direct cache access like so: 然后在另一个文件中,我进行一些直接缓存访问,如下所示:
from django.core.cache import cache
def getResults(self, key):
return cache.get(key)
看起来这是django-redis-cache
的未解决问题-也许您应该考虑使用支持连接池的Django的不同Redis缓存后端。
Here's django-redis-cache using connection-pool set max_connections. 这是使用连接池设置max_connections的django-redis-cache 。
CACHES = {
'default': {
'OPTIONS': {
'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool',
'CONNECTION_POOL_CLASS_KWARGS': {
'max_connections': 50,
'timeout': 20,
...
},
...
},
...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.