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
| Attribute | Type | Description |
|---|---|---|
| cache | dict = _DUMMY_CLIENT_CACHE | Internal 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
| Name | Type | Description |
|---|---|---|
| *args | any | Variable length argument list. |
| **kwargs | any | Arbitrary keyword arguments. |
Signature
def DummyClient(
*args: any,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Positional arguments for compatibility with other client interfaces. |
| **kwargs | any | Keyword 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
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier for the cached item to retrieve. |
| *args | any | Additional positional arguments ignored by the dummy implementation. |
| **kwargs | any | Additional keyword arguments ignored by the dummy implementation. |
Returns
| Type | Description |
|---|---|
any | The 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
| Name | Type | Description |
|---|---|---|
| keys | list | A collection of unique identifiers to look up in the cache. |
Returns
| Type | Description |
|---|---|
dict | A 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
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier used to store and later retrieve the value. |
| value | any | The data object to be stored in the cache. |
| *args | any | Additional positional arguments ignored by the dummy implementation. |
| **kwargs | any | Additional keyword arguments ignored by the dummy implementation. |
Returns
| Type | Description |
|---|---|
null | None |
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
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier of the cached item to be removed. |
| *args | any | Additional positional arguments ignored by the dummy implementation. |
| **kwargs | any | Additional keyword arguments ignored by the dummy implementation. |
Returns
| Type | Description |
|---|---|
null | None |
incr()
@classmethod
def incr(
key: string,
delta: integer
) - > integer
Increments the numeric value of a cached key by a specified delta.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier for the numeric value to increment. |
| delta | integer | The amount to add to the current value; defaults to 1. |
Returns
| Type | Description |
|---|---|
integer | The 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
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier of the cached item to update. |
| expire | integer | The new expiration time in seconds for the cached item. |
Returns
| Type | Description |
|---|---|
null | None |