bugix
This commit is contained in:
parent
62dce1d3d7
commit
f32f49fb85
@ -4,7 +4,7 @@ import aiofiles
|
|||||||
from random import randint
|
from random import randint
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from time import time
|
import time
|
||||||
from sqlor.dbpools import DBPools, get_sor_context
|
from sqlor.dbpools import DBPools, get_sor_context
|
||||||
from appPublic.log import debug, exception, error, critical
|
from appPublic.log import debug, exception, error, critical
|
||||||
from appPublic.uniqueID import getID
|
from appPublic.uniqueID import getID
|
||||||
@ -29,10 +29,10 @@ async def _get_uapi_cached(upappid, apiname):
|
|||||||
global _uapi_cache
|
global _uapi_cache
|
||||||
cache_key = f"{upappid}:{apiname}"
|
cache_key = f"{upappid}:{apiname}"
|
||||||
cached = _uapi_cache.get(cache_key)
|
cached = _uapi_cache.get(cache_key)
|
||||||
if cached and (time() - cached['ts']) < _UAPI_CACHE_TTL:
|
if cached and (time.time() - cached['ts']) < _UAPI_CACHE_TTL:
|
||||||
return cached['data']
|
return cached['data']
|
||||||
uapi_rec = await get_uapi(upappid, apiname)
|
uapi_rec = await get_uapi(upappid, apiname)
|
||||||
_uapi_cache[cache_key] = {'data': uapi_rec, 'ts': time()}
|
_uapi_cache[cache_key] = {'data': uapi_rec, 'ts': time.time()}
|
||||||
return uapi_rec
|
return uapi_rec
|
||||||
|
|
||||||
|
|
||||||
@ -42,14 +42,14 @@ async def _get_uapiio_cached(ioid):
|
|||||||
if ioid is None:
|
if ioid is None:
|
||||||
return None
|
return None
|
||||||
cached = _uapiio_cache.get(ioid)
|
cached = _uapiio_cache.get(ioid)
|
||||||
if cached and (time() - cached['ts']) < _UAPI_CACHE_TTL:
|
if cached and (time.time() - cached['ts']) < _UAPI_CACHE_TTL:
|
||||||
return cached['data']
|
return cached['data']
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
uapi_dbname = get_serverenv('get_module_dbname')('uapi')
|
uapi_dbname = get_serverenv('get_module_dbname')('uapi')
|
||||||
async with DBPools().sqlorContext(uapi_dbname) as sor:
|
async with DBPools().sqlorContext(uapi_dbname) as sor:
|
||||||
recs = await sor.R('uapiio', {'id': ioid})
|
recs = await sor.R('uapiio', {'id': ioid})
|
||||||
result = recs[0] if recs else None
|
result = recs[0] if recs else None
|
||||||
_uapiio_cache[ioid] = {'data': result, 'ts': time()}
|
_uapiio_cache[ioid] = {'data': result, 'ts': time.time()}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user