proxystore.endpoint.storage¶
Storage of the objects in an endpoint.
The Storage protocol is a simple
blob store. Storage implementations do not enforce limits on the size of
objects because the endpoint rejects objects which exceed its maximum object
size before they are read from the network. They may limit the total size of
the stored blobs and remove blobs a fixed time after they are stored.
Storage
¶
Bases: Protocol
Storage of the objects in an endpoint.
evict
async
¶
evict(key: str) -> None
Evict a blob from storage.
Evicting a key which does not exist is not an error.
Parameters:
-
key(str) –Key associated with blob to evict.
exists
async
¶
get
async
¶
get(key: str) -> MessageData | None
Get a blob from storage.
Parameters:
-
key(str) –Key associated with the blob to get.
Returns:
-
MessageData | None–The blob associated with the key or
Noneif it does not exist.
set
async
¶
set(key: str, blob: MessageData) -> None
Store the blob associated with a key.
Parameters:
-
key(str) –Key that will be used to retrieve the blob.
-
blob(MessageData) –Blob to store.
Raises:
-
StorageFullError–If the storage has a size limit and the blob does not fit.
Source code in proxystore/endpoint/storage.py
MemoryStorage
¶
Storage of blobs in memory.
Blobs are lost when the storage is closed.
Parameters:
-
max_size(int | None, default:None) –Maximum total size in bytes of the stored blobs. Storing a blob which does not fit raises a
StorageFullErrorrather than removing other blobs. IfNone, there is no limit. -
ttl(float | None, default:None) –Seconds after a blob is stored that it expires and is removed. If
None, blobs do not expire.
Source code in proxystore/endpoint/storage.py
exists
async
¶
get
async
¶
get(key: str) -> MessageData | None
Get a blob from storage.
Parameters:
-
key(str) –Key associated with the blob to get.
Returns:
-
MessageData | None–The blob associated with the key or
Noneif it does not exist.
Source code in proxystore/endpoint/storage.py
set
async
¶
set(key: str, blob: MessageData) -> None
Store the blob associated with a key.
Parameters:
-
key(str) –Key that will be used to retrieve the blob.
-
blob(MessageData) –Blob to store.
Raises:
-
StorageFullError–If the blob does not fit within
max_size. A blob already stored with the key is kept.
Source code in proxystore/endpoint/storage.py
SQLiteStorage
¶
Storage of blobs in a SQLite database.
The database uses write-ahead logging with synchronous=NORMAL, so
commits are not synced to disk one at a time. The database is never
corrupted, and a crash of the endpoint loses no blobs, but a crash of
the operating system or a power loss can lose the most recently stored
blobs. The database is locked while the storage is open, so other
processes cannot open it.
Parameters:
-
database_path(str | Path, default:':memory:') –Path to database file.
~is expanded to the user's home directory. Use":memory:"for a database which is only stored in memory. -
ttl(float | None, default:None) –Seconds after a blob is stored that it expires and is removed. When the database is opened, blobs without an expiry time expire
ttlseconds later. IfNone, blobs do not expire, and expiry times of blobs already in the database are removed.
Source code in proxystore/endpoint/storage.py
db
async
¶
Get the database connection object.
Source code in proxystore/endpoint/storage.py
evict
async
¶
evict(key: str) -> None
exists
async
¶
Check if a blob exists in the storage.
Parameters:
-
key(str) –Key associated with the blob to check.
Returns:
-
bool–If a blob associated with the key exists.
Source code in proxystore/endpoint/storage.py
get
async
¶
get(key: str) -> MessageData | None
Get a blob from storage.
Parameters:
-
key(str) –Key associated with the blob to get.
Returns:
-
MessageData | None–The blob associated with the key or
Noneif it does not exist.
Source code in proxystore/endpoint/storage.py
set
async
¶
set(key: str, blob: MessageData) -> None
Store the blob associated with a key.
Parameters:
-
key(str) –Key that will be used to retrieve the blob.
-
blob(MessageData) –Blob to store.