[#3] Added generate proto script create container method

Signed-off-by: Ilyas Niyazov <i.niyazov@yadro.com>
This commit is contained in:
Ilyas Niyazov 2025-03-25 11:10:30 +03:00
parent fba6eaaa9c
commit d2e0c80f7c
16 changed files with 348 additions and 51 deletions

View 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