Skip to content

About

High-performance semantic vector cache for LLM queries in Python with Redis and cosine similarity deduplication

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

vector-cache-redis

CI License: MIT Python 3.12

High-throughput semantic vector cache in Python 3.11+ for LLM API cost reduction with deterministic feature-hashed embeddings, OrderedDict O(1) LRU eviction, monotonic TTL expiration, namespace isolation, and pipeline batch endpoints.

Features

  • Semantic Feature Hashing: L2-normalized word unigrams + character trigrams compute meaningful cosine similarity for paraphrased queries (zero external model overhead).
  • LRU + TTL State Machine: O(1) access reordering, capacity-bounded eviction, automatic expiration sweeps, and hit-rate / eviction telemetry.
  • Namespace Isolation & Pipelining: Isolate caches by tenant or LLM model (namespace) and execute batch pipeline/store & pipeline/lookup.
  • REST API: /health, POST /api/v1/cache/store, POST /api/v1/cache/lookup, POST /api/v1/cache/pipeline/{store,lookup}, DELETE /api/v1/cache, GET /api/v1/cache/stats.

Quick Start

ruff check .
pytest -v tests/

About

High-performance semantic vector cache for LLM queries in Python with Redis and cosine similarity deduplication

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages