Skip to main content

DummyClient

This class provides a simplified, in-memory key-value store interface for caching data. It supports basic operations such as retrieving, setting, and deleting individual or multiple keys, as well as incrementing numeric values. The class is designed to mimic a standard cache client for testing or lightweight storage purposes.

Attributes

AttributeTypeDescription
cachedict = _DUMMY_CLIENT_CACHEInternal storage dictionary used to simulate a cache backend for storing and retrieving key-value pairs.

Constructor

Signature

def DummyClient(
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*argsanyVariable length argument list.
**kwargsanyArbitrary keyword arguments.

Signature

def DummyClient(
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*argsanyPositional arguments for compatibility with other client interfaces.
**kwargsanyKeyword arguments for compatibility with other client interfaces.

Methods


get()

@classmethod
def get(
key: string,
*args: any,
**kwargs: any
) - > any

Retrieves the value associated with a specific key from the cache.

Parameters

NameTypeDescription
keystringThe unique identifier for the cached item to retrieve.
*argsanyAdditional positional arguments ignored by the dummy implementation.
**kwargsanyAdditional keyword arguments ignored by the dummy implementation.

Returns

TypeDescription
anyThe value stored in the cache for the given key, or None if the key does not exist.

get_multi()

@classmethod
def get_multi(
keys: list
) - > dict

Fetches multiple values from the cache simultaneously for a provided list of keys.

Parameters

NameTypeDescription
keyslistA collection of unique identifiers to look up in the cache.

Returns

TypeDescription
dictA dictionary mapping existing keys to their respective cached values.

set()

@classmethod
def set(
key: string,
value: any,
*args: any,
**kwargs: any
) - > null

Stores a value in the cache under the specified key, overwriting any existing data.

Parameters

NameTypeDescription
keystringThe unique identifier used to store and later retrieve the value.
valueanyThe data object to be stored in the cache.
*argsanyAdditional positional arguments ignored by the dummy implementation.
**kwargsanyAdditional keyword arguments ignored by the dummy implementation.

Returns

TypeDescription
nullNone

delete()

@classmethod
def delete(
key: string,
*args: any,
**kwargs: any
) - > null

Removes a specific key and its associated value from the cache if it exists.

Parameters

NameTypeDescription
keystringThe unique identifier of the cached item to be removed.
*argsanyAdditional positional arguments ignored by the dummy implementation.
**kwargsanyAdditional keyword arguments ignored by the dummy implementation.

Returns

TypeDescription
nullNone

incr()

@classmethod
def incr(
key: string,
delta: integer
) - > integer

Increments the numeric value of a cached key by a specified delta.

Parameters

NameTypeDescription
keystringThe unique identifier for the numeric value to increment.
deltaintegerThe amount to add to the current value; defaults to 1.

Returns

TypeDescription
integerThe new value of the key after the increment operation has been applied.

touch()

@classmethod
def touch(
key: string,
expire: integer
) - > null

Updates the expiration time of a cached key without modifying its value.

Parameters

NameTypeDescription
keystringThe unique identifier of the cached item to update.
expireintegerThe new expiration time in seconds for the cached item.

Returns

TypeDescription
nullNone