一.
SESSION_REDIS = redis://root:admin123456@47.115.1.74/1
USER_REDIS = redis://root:admin123456@47.115.1.74/2
CONFIG_REDIS = redis://root:admin123456@47.115.1.74/3
ADMIN_USER_REDIS = redis://root:admin123456@47.115.1.74/7
二.
class Clients:
@lazy_property
def user_redis(self):
import redis
return redis.Redis(connection_pool=redis.BlockingConnectionPool.from_url(settings.USER_REDIS))
@lazy_property
def session_redis(self):
import redis
return redis.Redis(connection_pool=redis.BlockingConnectionPool.from_url(settings.SESSION_REDIS))
@lazy_property
def config_redis(self):
import redis
return redis.Redis(connection_pool=redis.BlockingConnectionPool.from_url(settings.CONFIG_REDIS))
@lazy_property
def admin_user_redis(self):
import redis
return redis.Redis(connection_pool=redis.BlockingConnectionPool.from_url(settings.ADMIN_USER_REDIS))
clients = Clients()
三.
import clients
sms_provider = clients.user_redis.get("verification_code")
网友评论