hyperion.ports.keyval¶
hyperion.ports.keyval
¶
Port: key-value store abstraction.
Abstract :class:KeyValueStore base, the :data:CompressionType alias and
the :func:is_valid_compression_type guard. If you need a store with a TTL,
look at :class:hyperion.ports.cache.Cache instead. Concrete adapters
(DynamoDBStore, InMemoryStore, FilesystemStore) live in
hyperion.adapters.keyval.*.
KeyValueStore
¶
Bases: ABC, Iterable[str]
A key-value store.
Initialize the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str | None
|
A prefix to add to all keys. |
None
|
compression
|
CompressionType | None
|
The compression algorithm to use. |
None
|
Source code in hyperion/ports/keyval.py
get
¶
set
¶
keys
¶
Iterate all keys available in the store that match the given expression.
Nothing fancy is supported, UNIX-style fnmatch is performed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
str
|
The expression to match. |
'*'
|
Returns:
| Type | Description |
|---|---|
Iterable[str]
|
Iterable[str]: The keys that match the expression |
Source code in hyperion/ports/keyval.py
delete
¶
Delete a value from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to delete. |
required |
exists
¶
Returns whether a key exists in the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to check. |
required |