jacinle.storage.kv.mem#

Classes

MemKVStore

A simple in-memory key-value store.

Class MemKVStore

class MemKVStore[source]#

Bases: KVStoreBase

A simple in-memory key-value store.

__init__(readonly=False)[source]#

Initialize the KVStore.

Parameters:

readonly – If True, the KVStore is readonly.

__new__(**kwargs)#
erase(key, **kwargs)#

Erase the key from the KVStore.

Parameters:

key – the key.

get(key, default=None, **kwargs)#

Get the value of the key.

Parameters:
  • key – the key.

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

has(key, **kwargs)#

Whether the key exists in the KVStore.

Return type:

bool

keys(**kwargs)#

Get all keys in the KVStore.

Return type:

Iterable[Any]

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

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)#

Create a transaction context.

update(key, value, **kwargs)#

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.