dev
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
from api.core.Gzip import gzip_zip, gzip_unzip
|
from api.core.Gzip import gzip_zip, gzip_unzip
|
||||||
from config.main import config
|
from config.main import config
|
||||||
|
|
||||||
|
|
||||||
def get_redis_info(redis, key, fun, expire = 0, without_gzip=False):
|
async def get_redis_info(redis, key, fun, expire = 0, without_gzip=False):
|
||||||
info = None
|
info = None
|
||||||
if not config.DEBUG_MODE and redis:
|
if not config.DEBUG_MODE and redis:
|
||||||
try:
|
try:
|
||||||
@@ -14,7 +15,10 @@ def get_redis_info(redis, key, fun, expire = 0, without_gzip=False):
|
|||||||
except Exception:
|
except Exception:
|
||||||
info = None
|
info = None
|
||||||
if info is None:
|
if info is None:
|
||||||
info = fun()
|
if inspect.iscoroutinefunction(fun):
|
||||||
|
info = await fun()
|
||||||
|
else:
|
||||||
|
info = fun()
|
||||||
if not config.DEBUG_MODE and redis and info is not None:
|
if not config.DEBUG_MODE and redis and info is not None:
|
||||||
if without_gzip:
|
if without_gzip:
|
||||||
redis.set(key, json.dumps(info))
|
redis.set(key, json.dumps(info))
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ async def get_official_gold(redis: RedisDep) -> Response[list[OfficialGold]]:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return response(data=[])
|
return response(data=[])
|
||||||
|
|||||||
Reference in New Issue
Block a user