jacinle.storage.kv.base#

Classes

KVStoreBase

The base class for all key-value stores.

Class KVStoreBase

class KVStoreBase[source]#

Bases: object

The base class for all key-value stores.

__init__(readonly=False)[source]#

Initialize the KVStore.

Parameters:

readonly (bool) – If True, the KVStore is readonly.

__new__(**kwargs)#
erase(key, **kwargs)[source]#

Erase the key from the KVStore.

Parameters:

key – the key.

get(key, default=None, **kwargs)[source]#

Get the value of the key.

Parameters:
  • key – the key.

  • default – the default value if the key does not exist.

has(key, **kwargs)[source]#

Whether the key exists in the KVStore.

Return type:

bool

keys(**kwargs)[source]#

Get all keys in the KVStore.

Return type:

Iterable[Any]

put(key, value, replace=True, **kwargs)[source]#

Put the value of the key. If the key already exists, the value will be replaced if replace is True.

Parameters:
  • key – the key.

  • value – the value.

  • replace (bool) – whether to replace the value if the key already exists.

transaction(*args, **kwargs)[source]#

Create a transaction context.

update(key, value, **kwargs)[source]#

Update the value of the key. If the key does not exist, the value will be put.

Parameters:
  • key – the key.

  • value – the value.

property readonly#

Whether the KVStore is readonly.