lmcache.storage_backend.connector package#

Submodules#

lmcache.storage_backend.connector.base_connector module#

class lmcache.storage_backend.connector.base_connector.RemoteConnector[source]#

Interface for remote connector

abstract close() None[source]#

Close remote server

abstract exists(key: str) bool[source]#

Check if the remote server contains the key

Input:

key: a string

Returns:

True if the cache engine contains the key, False otherwise

abstract get(key: str) bytes | None[source]#

Get the objects (bytes) of the corresponding key

Input:

key: the key of the corresponding object

Returns:

The object (bytes) of the corresponding key Return None if the key does not exist

abstract list() List[str][source]#

List all keys in the remote server

Returns:

A list of keys in the remote server

abstract set(key: str, obj: bytes) None[source]#

Send the objects (bytes) with the corresponding key to the remote server

Input:

key: the key of the corresponding object obj: the object (bytes) of the corresponding key

class lmcache.storage_backend.connector.base_connector.RemoteConnectorDebugWrapper(connector: RemoteConnector)[source]#

Bases: RemoteConnector

close() None[source]#

Close remote server

exists(key: str) bool[source]#

Check if the remote server contains the key

Input:

key: a string

Returns:

True if the cache engine contains the key, False otherwise

get(key: str) bytes | None[source]#

Get the objects (bytes) of the corresponding key

Input:

key: the key of the corresponding object

Returns:

The object (bytes) of the corresponding key Return None if the key does not exist

list() List[str][source]#

List all keys in the remote server

Returns:

A list of keys in the remote server

set(key: str, obj: bytes) None[source]#

Send the objects (bytes) with the corresponding key to the remote server

Input:

key: the key of the corresponding object obj: the object (bytes) of the corresponding key

lmcache.storage_backend.connector.lm_connector module#

class lmcache.storage_backend.connector.lm_connector.LMCServerConnector(host, port)[source]#

Bases: RemoteConnector

close()[source]#

Close remote server

exists(key: str) bool[source]#

Check if the remote server contains the key

Input:

key: a string

Returns:

True if the cache engine contains the key, False otherwise

get(key: str) bytes | None[source]#

Get the objects (bytes) of the corresponding key

Input:

key: the key of the corresponding object

Returns:

The object (bytes) of the corresponding key Return None if the key does not exist

list() List[str][source]#

List all keys in the remote server

Returns:

A list of keys in the remote server

receive_all(n)[source]#
send_all(data)[source]#

Thread-safe function to send the data

set(key: str, obj: bytes)[source]#

Send the objects (bytes) with the corresponding key to the remote server

Input:

key: the key of the corresponding object obj: the object (bytes) of the corresponding key

lmcache.storage_backend.connector.redis_connector module#

class lmcache.storage_backend.connector.redis_connector.RedisConnector(host: str, port: int)[source]#

Bases: RemoteConnector

The remote url should start with “redis://” and only have one host-port pair

close()[source]#

Close remote server

exists(key: str) bool[source]#

Check if the remote server contains the key

Input:

key: a string

Returns:

True if the cache engine contains the key, False otherwise

get(key: str) bytes | None[source]#

Get the objects (bytes) of the corresponding key

Input:

key: the key of the corresponding object

Returns:

The object (bytes) of the corresponding key Return None if the key does not exist

list()[source]#

List all keys in the remote server

Returns:

A list of keys in the remote server

set(key: str, obj: bytes) None[source]#

Send the objects (bytes) with the corresponding key to the remote server

Input:

key: the key of the corresponding object obj: the object (bytes) of the corresponding key

class lmcache.storage_backend.connector.redis_connector.RedisSentinelConnector(hosts_and_ports: List[Tuple[str, str | int]])[source]#

Bases: RemoteConnector

Uses redis.Sentinel to connect to a Redis cluster. The hosts are specified in the config file, started with “redis-sentinel://” and separated by commas.

Example

remote_url: “redis-sentinel://localhost:26379,localhost:26380,localhost:26381”

Extra environment variables: - REDIS_SERVICE_NAME (required) – service name for redis. - REDIS_TIMEOUT (optional) – Timeout in seconds, default is 1 if not set

ENV_REDIS_SERVICE_NAME = 'REDIS_SERVICE_NAME'#
ENV_REDIS_TIMEOUT = 'REDIS_TIMEOUT'#
close()[source]#

Close remote server

exists(key: str) bool[source]#

Check if the remote server contains the key

Input:

key: a string

Returns:

True if the cache engine contains the key, False otherwise

get(key: str) bytes | None[source]#

Get the objects (bytes) of the corresponding key

Input:

key: the key of the corresponding object

Returns:

The object (bytes) of the corresponding key Return None if the key does not exist

list()[source]#

List all keys in the remote server

Returns:

A list of keys in the remote server

set(key: str, obj: bytes) None[source]#

Send the objects (bytes) with the corresponding key to the remote server

Input:

key: the key of the corresponding object obj: the object (bytes) of the corresponding key