Remote caches operate outside the Python process, allowing multiple application instances to share a single cache store and persist entries beyond a process restart. Kimera Core provides two remote adapters —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ismael-sarmiento/kimera_python/llms.txt
Use this file to discover all available pages before exploring further.
RedisEngine for Redis and MemcachedEngine for Memcached — both implementing the same BaseCacheEngine abstract interface as the local engines. Use Redis when you need optional TTL configuration, key inspection, or pub/sub alongside caching; use Memcached when you want a simpler, high-throughput store with minimal overhead and are comfortable with its fire-and-forget semantics.
Prerequisites
Neither adapter ships with a hard dependency. The required client library is imported lazily at instantiation time; if the package is missing,ImportUtils.raise_exception_if_module_not_exists raises a ModuleNotFoundError before any network connection is attempted.
Redis
Install the client and start a Redis server:Default connection:
localhost:6379Memcached
Install the client and start a Memcached server:Default connection:
localhost:11211If the optional package is not installed, instantiation raises
ModuleNotFoundError immediately rather than at the first cache operation, making the missing dependency obvious at startup.RedisEngine
RedisEngine connects to Redis using redis.Redis() with its default settings, which resolve to localhost on port 6379. The underlying client is stored as self._redis and is reused for the lifetime of the engine instance.
Methods
get(key: str) -> object
get(key: str) -> object
Calls
redis.get(key). Returns the stored bytes value, or None if the key does not exist. Note that Redis always returns values as bytes — decode as needed.set(key: str, value: object, timeout: float = None, size: int = None) -> None
set(key: str, value: object, timeout: float = None, size: int = None) -> None
Calls
self._redis.set(key, value, timeout), passing timeout as the third positional argument to the Redis client. The size parameter is accepted for interface compatibility but is not used.exists(key: str) -> bool
exists(key: str) -> bool
Calls
self.get(key) and returns True if the result is not None.delete(key: str) -> None
delete(key: str) -> None
Calls
redis.delete(key) to remove the key from the Redis store.clear() -> None
clear() -> None
Calls
redis.flushall(), which removes all keys from all databases on the connected Redis server. Use with care in shared environments.close() -> None
close() -> None
Closes the underlying Redis connection. Call this when the engine is no longer needed to release the connection back to the pool.
Example
Redis serializes all values to bytes. If you store a Python string such as
'bearer_abc123', get returns b'bearer_abc123'. Decode the result with .decode('utf-8') or use KimeraSerializer to round-trip complex objects through Redis.MemcachedEngine
MemcachedEngine connects to Memcached using pymemcache.client.base.Client pointed at ('localhost', 11211). The client is stored as self._client.
Methods
get(key: str) -> object
get(key: str) -> object
Calls
client.get(key). Returns the cached value, or None if the key does not exist or has expired.set(key: str, value: object, timeout: float = None, size: int = None) -> None
set(key: str, value: object, timeout: float = None, size: int = None) -> None
Calls
client.set(key, value). The timeout and size parameters are accepted for interface compatibility; TTL configuration is not yet wired through to the underlying Memcached expire argument.exists(key: str) -> bool
exists(key: str) -> bool
Calls
self.get(key) and returns True if the result is not None.delete(key: str) -> None
delete(key: str) -> None
Calls
client.delete(key) to remove the key from Memcached.clear() -> None
clear() -> None
Calls
client.flush_all(), invalidating all entries in the connected Memcached instance.close() -> None
close() -> None
Closes the underlying Memcached connection.
Example
Shared Interface
BothRedisEngine and MemcachedEngine implement the same BaseCacheEngine ABC that the local engines descend from. This means they are drop-in replacements for InMemoryCacheEngine or ThreadCacheEngine in any code that depends on the abstract interface:
get, set, delete, exists, and clear. The close method is additional on remote engines and has no equivalent on local engines.