1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-19 10:03:49 +03:00

Update cache timeout constants in cache.py and client.py

This commit is contained in:
Adolfo Gómez García 2024-04-16 22:53:35 +02:00
parent 229962cbd2
commit 60c5f37591
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ DEFAULT_CACHE_TIMEOUT: typing.Final[int] = 60 * 3 # 3 minutes
LONG_CACHE_TIMEOUT: typing.Final[int] = DEFAULT_CACHE_TIMEOUT * 20 # 1 hour LONG_CACHE_TIMEOUT: typing.Final[int] = DEFAULT_CACHE_TIMEOUT * 20 # 1 hour
EXTREME_CACHE_TIMEOUT: typing.Final[int] = LONG_CACHE_TIMEOUT * 24 # 1 day EXTREME_CACHE_TIMEOUT: typing.Final[int] = LONG_CACHE_TIMEOUT * 24 # 1 day
SHORT_CACHE_TIMEOUT: typing.Final[int] = DEFAULT_CACHE_TIMEOUT // 3 # 1 minute SHORT_CACHE_TIMEOUT: typing.Final[int] = DEFAULT_CACHE_TIMEOUT // 3 # 1 minute
SMALLEST_CACHE_TIMEOUT: typing.Final[int] = 3 # 3 seconds SHORTEST_CACHE_TIMEOUT: typing.Final[int] = 3 # 3 seconds
# Used to mark a cache as not found # Used to mark a cache as not found
# use "cache.get(..., default=CACHE_NOT_FOUND)" to check if a cache is non existing instead of real None value # use "cache.get(..., default=CACHE_NOT_FOUND)" to check if a cache is non existing instead of real None value

View File

@ -165,7 +165,7 @@ class Client:
for vm in typing.cast(list[typing.Any], self.api.system_service().vms_service().list()) for vm in typing.cast(list[typing.Any], self.api.system_service().vms_service().list())
] ]
@decorators.cached(prefix='o-vm', timeout=consts.cache.SMALLEST_CACHE_TIMEOUT, key_helper=_key_helper) @decorators.cached(prefix='o-vm', timeout=consts.cache.SHORTEST_CACHE_TIMEOUT, key_helper=_key_helper)
def get_machine_info(self, vmid: str, **kwargs: typing.Any) -> ov_types.VMInfo: def get_machine_info(self, vmid: str, **kwargs: typing.Any) -> ov_types.VMInfo:
with _access_lock(): with _access_lock():
try: try:
@ -416,7 +416,7 @@ class Client:
# This returns nothing, if it fails it raises an exception # This returns nothing, if it fails it raises an exception
@decorators.cached( @decorators.cached(
prefix='o-templates', timeout=consts.cache.SMALLEST_CACHE_TIMEOUT, key_helper=_key_helper prefix='o-templates', timeout=consts.cache.SHORTEST_CACHE_TIMEOUT, key_helper=_key_helper
) )
def list_snapshots(self, vmid: str) -> list[ov_types.SnapshotInfo]: def list_snapshots(self, vmid: str) -> list[ov_types.SnapshotInfo]:
""" """
@ -433,7 +433,7 @@ class Client:
for s in typing.cast(list[typing.Any], vm_service.snapshots_service().list()) for s in typing.cast(list[typing.Any], vm_service.snapshots_service().list())
] ]
@decorators.cached(prefix='o-snapshot', timeout=consts.cache.SMALLEST_CACHE_TIMEOUT, key_helper=_key_helper) @decorators.cached(prefix='o-snapshot', timeout=consts.cache.SHORTEST_CACHE_TIMEOUT, key_helper=_key_helper)
def get_snapshot_info(self, vmid: str, snapshot_id: str) -> ov_types.SnapshotInfo: def get_snapshot_info(self, vmid: str, snapshot_id: str) -> ov_types.SnapshotInfo:
""" """
Returns the snapshot info for the given snapshot id Returns the snapshot info for the given snapshot id