[#3] Added generate proto script create container method
Signed-off-by: Ilyas Niyazov <i.niyazov@yadro.com>
This commit is contained in:
parent
19282f13cc
commit
3afa14db95
52 changed files with 1381 additions and 74 deletions
39
frostfs_sdk/client/utils/session_cache.py
Normal file
39
frostfs_sdk/client/utils/session_cache.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SessionToken:
|
||||
token: bytes
|
||||
|
||||
|
||||
class SessionCache:
|
||||
def __init__(self, session_expiration_duration):
|
||||
self.cache = {}
|
||||
self.token_duration = session_expiration_duration
|
||||
self.current_epoch = 0
|
||||
|
||||
|
||||
def contains(self, key: str):
|
||||
return key in self.cache
|
||||
|
||||
def try_get_value(self, key: str) -> Optional[SessionToken]:
|
||||
if not key:
|
||||
return None
|
||||
return self.cache.get(key)
|
||||
|
||||
|
||||
def set_value(self, key: str, value: SessionToken):
|
||||
if key is not None:
|
||||
self.cache[key] = value
|
||||
|
||||
def delete_by_prefix(self, prefix: str):
|
||||
# Collect keys to avoid modifying dictionary during iteration
|
||||
keys_to_delete = [key for key in self.cache if key.startswith(prefix)]
|
||||
for key in keys_to_delete:
|
||||
del self.cache[key]
|
||||
|
||||
@staticmethod
|
||||
def form_cache_key(address: str, key: str):
|
||||
return address + key
|
Loading…
Add table
Add a link
Reference in a new issue