You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
458 B
21 lines
458 B
from redis import Redis, ConnectionPool
|
|
from django.conf import settings
|
|
|
|
_pool = None
|
|
|
|
|
|
def get_redis_pool():
|
|
global _pool
|
|
if _pool is None:
|
|
redis_url = getattr(settings, 'REDIS_URL', 'redis://127.0.0.1:6379/0')
|
|
_pool = ConnectionPool.from_url(url=redis_url, max_connections=100)
|
|
return _pool
|
|
|
|
|
|
class RedisConfig:
|
|
|
|
def __init__(self):
|
|
self.redis = Redis(connection_pool=get_redis_pool(), decode_responses=True)
|
|
|
|
|
|
|