Skip to main content

Storage Backends

Chengeta AI provides nine interchangeable backends — four key-value stores, one tiered backend, one async backend, and three vector similarity stores. Every backend conforms to a Protocol, so you can swap implementations without changing application code.


Key-Value Backends (CacheBackend)

BackendClassExtrasBest For
In-Memory (LRU)InMemoryBackend— (core)Dev, testing, single-process
Async In-MemoryAsyncInMemoryBackend— (core)FastAPI, async LangGraph
Tiered (L1+L2)TieredBackend— (core)Memory speed + Redis persistence
DiskDiskBackend— (core)Single-node persistence
RedisRedisBackend[redis]Shared across processes / services

Vector Backends (VectorBackend)

BackendClassExtrasBest For
FAISSFAISSBackend[vector-faiss]Fast in-process similarity
ChromaDBChromaBackend[vector-chroma]Persistent vector store + metadata
QdrantQdrantBackend[vector-qdrant]Production scale (22ms p95)
WeaviateWeaviateBackend[vector-weaviate]Hybrid search (vector + BM25)

Decision Flowchart


Protocols

Both protocols are @runtime_checkable — verify with isinstance().

CacheBackend

from chengeta_ai.backends.base import CacheBackend
# get / set / delete / exists / clear / close

AsyncCacheBackend

from chengeta_ai.backends.async_base import AsyncCacheBackend
# async get / set / delete / exists / clear / close

VectorBackend

from chengeta_ai.backends.base import VectorBackend
# add / search / delete / clear / close

Custom Backend

Implement the CacheBackend protocol — no inheritance required:

class MyBackend:
def get(self, key: str): ...
def set(self, key: str, value, ttl=None): ...
def delete(self, key: str): ...
def exists(self, key: str) -> bool: ...
def clear(self): ...
def close(self): ...