jacinle.storage.kv.memcached#

Classes

MemcachedKVStore

A memcached-based key-value store.

Class MemcachedKVStore

class MemcachedKVStore[source]#

Bases: KVStoreBase

A memcached-based key-value store.

__init__(addr, port, readonly=False)[source]#

Initialize the MemcachedKVStore.

Parameters:
  • addr (str) – the address of the memcached server.

  • port (str | int) – the port of the memcached server.

  • readonly (bool) – whether 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.

addr: str#

The address of the memcached server.

available: bool#

Whether the memcached is available.

property connection#

The connection to the memcached server.

full_addr: str#

The full address of the memcached server.

port: str | int#

The port of the memcached server.

property readonly#

Whether the KVStore is readonly.