|
@@ -2,20 +2,20 @@ import redis
|
|
|
from datetime import timedelta
|
|
|
|
|
|
|
|
|
-class SyncRedisHelper(object):
|
|
|
+class SyncRedisHelper:
|
|
|
_pool: redis.ConnectionPool = None
|
|
|
_instance = None
|
|
|
|
|
|
- def __new__(cls, *args, **kwargs):
|
|
|
- if cls._instance is None:
|
|
|
- cls._instance = super().__new__(cls, *args, **kwargs)
|
|
|
- return cls._instance
|
|
|
+ def __init__(self, *args, **kwargs):
|
|
|
+ if not self._instance:
|
|
|
+ self._pool = self._get_pool()
|
|
|
+ self._instance = self
|
|
|
|
|
|
def _get_pool(self) -> redis.ConnectionPool:
|
|
|
if self._pool is None:
|
|
|
self._pool = redis.ConnectionPool(
|
|
|
- # host="r-bp154bpw97gptefiqkpd.redis.rds.aliyuncs.com", # 外网地址
|
|
|
host="r-bp1mb0v08fqi4hjffu.redis.rds.aliyuncs.com", # 内网地址
|
|
|
+ # host="r-bp154bpw97gptefiqkpd.redis.rds.aliyuncs.com", # 外网地址
|
|
|
port=6379,
|
|
|
db=1,
|
|
|
password="Qingqu2019",
|
|
@@ -55,8 +55,8 @@ def get_data(platform, out_video_id):
|
|
|
# store_data('xiaoniangao', '12345')
|
|
|
|
|
|
# 示例:获取一个数据
|
|
|
-# value = get_data('xiaoniangao', '12345')
|
|
|
-# if value is None:
|
|
|
-# print("Value does not exist")
|
|
|
-# else:
|
|
|
-# print(f"Retrieved value: {value}")
|
|
|
+value = get_data('xiaoniangao', '12345')
|
|
|
+if value is None:
|
|
|
+ print("Value does not exist")
|
|
|
+else:
|
|
|
+ print(f"Retrieved value: {value}")
|