feat: respect module_cache config for UAPI cache

This commit is contained in:
yumoqing 2026-05-29 17:59:26 +08:00
parent 4892a4e460
commit 77b4b14525

View File

@ -8,10 +8,23 @@ from appPublic.streamhttpclient import StreamHttpClient, liner
from appPublic.dictObject import DictObject
from appPublic.log import debug, exception, error
from appPublic.aes import aes_encode_b64
from appPublic.jsonConfig import getConfig
from ahserver.globalEnv import password_decode
from ahserver.serverenv import get_serverenv, ServerEnv
from random import randint
def _cache_enabled():
"""Check if cache is enabled for uapi module in config.json"""
try:
config = getConfig()
module_cache = config.module_cache
if module_cache is None:
return True
return getattr(module_cache, 'uapi', True)
except Exception:
return True
async def get_deerer(upappid, callerid):
db = DBPools()
dbname = get_dbname()
@ -69,9 +82,10 @@ class UAPIData:
async def get_apiusers(self, appid, orgid=None):
key = appid
d = self.org_users.get(key)
if d:
return d
if _cache_enabled():
d = self.org_users.get(key)
if d:
return d
env = ServerEnv()
async with get_sor_context(env, 'uapi') as sor:
sql = """select
@ -122,9 +136,10 @@ where b.orgid = c.ownerid
async def get_api(self, appid, apiname):
key = f'{appid}.{apiname}'
api = self.apidata.get(key)
if api:
return api
if _cache_enabled():
api = self.apidata.get(key)
if api:
return api
env = ServerEnv()
async with get_sor_context(env, 'uapi') as sor:
d = await sor_get_uapi(sor, appid, apiname)