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:
parent
229962cbd2
commit
60c5f37591
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user