123456789101112131415161718192021222324252627 |
- import redis
- class DbRedis:
- __connection = None
- @staticmethod
- def connect():
- if DbRedis.__connection is None:
- host = 'r-2ze28bdb7389a8a4614.redis.rds.aliyuncs.com'
- # host = 'r-2ze28bdb7389a8a4pd.redis.rds.aliyuncs.com'
- port = 6379
- password = 'Zhuaduoduo2017'
- DbRedis.__connection = redis.StrictRedis(
- host=host,
- port=port,
- password=password,
- decode_responses=True
- )
- print('Redis 连接成功!')
- return DbRedis.__connection
|