1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

core/storage: Add delete() method to storage.cache.

This commit is contained in:
Andrew Kozlik 2020-08-03 18:14:48 +02:00 committed by Andrew Kozlik
parent 5c1f197602
commit 8bcb3d8fb6

View File

@ -73,6 +73,17 @@ def get(key: int) -> Any:
return _caches[_active_session_id].get(key)
def delete(key: int) -> None:
if key & _SESSIONLESS_FLAG:
if key in _sessionless_cache:
del _sessionless_cache[key]
return
if _active_session_id is None:
raise RuntimeError # no session active
if key in _caches[_active_session_id]:
del _caches[_active_session_id][key]
def stored(key: int) -> Callable[[F], F]:
def decorator(func: F) -> F:
# if we didn't check this, it would be easy to store an Awaitable[something]