Storage
A key/value store for the SDK's state.
Protocol in sponsorkit.storage.
from sponsorkit import StorageAlso importable from sponsorkit.storage.
class Storage(Protocol):
...A key/value store for the SDK's state. Keys are targets_hash values; values are JSON text.
Implement this to keep Sponsorkit's state somewhere else (for example an OS keychain). Implementations must make write() atomic: a concurrent read() sees either the old or the new value, never a partial one.
Implement the methods below on any class; no subclassing is needed (it is a runtime_checkable Protocol).
Methods#
read()#
def read(self, key: str) -> str | NoneReturn the stored JSON text, or None if nothing is stored.
write()#
def write(self, key: str, data: str) -> NoneAtomically replace the stored JSON text.
delete()#
def delete(self, key: str) -> NoneRemove the stored value, if any.