lix-open-cache
Standalone multi-layer caching and session management for conversational AI. Works with just Redis — no server needed.
pip install lix-open-cache
Quick Start
from lix_open_cache import CacheConfig, CacheCoordinator
config = CacheConfig(redis_host="localhost", redis_port=6379)
cache = CacheCoordinator(session_id="user-abc", config=config)
# Store & retrieve conversation context
cache.add_message_to_context("user", "What's the weather in Tokyo?")
cache.add_message_to_context("assistant", "22C and sunny.")
history = cache.get_context_messages()
# Semantic cache — skip LLM on similar queries
import numpy as np
embedding = np.random.rand(384).astype(np.float32)
cached = cache.get_semantic_response("https://weather.com", embedding)
Three Cache Layers
| Layer | Purpose | Backend | TTL |
|---|---|---|---|
| Session Context Window | Rolling 20-message window + disk overflow | Redis DB 2 + .huff files |
24h |
| Semantic Query Cache | Deduplicate similar queries (cosine >= 0.90) | Redis DB 0 | 5 min |
| URL Embedding Cache | Cache embedding vectors per URL | Redis DB 1 | 24h |
Key Features
- Two-tier hybrid storage — Redis hot window + Huffman-compressed disk archive
- LRU eviction daemon — auto-migrates idle sessions to disk, re-hydrates on return
- smart_context() — recent messages + semantically relevant history from disk
- Pure Python Huffman codec — ~54% compression, zero native dependencies
- CacheConfig dataclass — all tunables in one place, 12-factor env var support
Dependencies
Only 3: redis, numpy, loguru
Research Paper
A Three-Layer Caching Architecture for Low-Latency LLM Web Search on Commodity CPU Hardware Ayushman Bhattacharya, 2026 Read the paper
License
MIT
Metadata
Release files for lix-open-cache 2.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lix_open_cache-2.1.6.tar.gz | 14.2 kB | Without provenance | Details for lix_open_cache-2.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lix_open_cache-2.1.6-py3-none-any.whl | Python 3 | none | any | Details for lix_open_cache-2.1.6-py3-none-any.whl |
Total release size: 30.5 kB
Release files / lix_open_cache-2.1.6.tar.gz
| Download URL | lix_open_cache-2.1.6.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a7bc8910811dfb453e1d6ef57b49988c00b86738fa0126f6f4321af260683b5
|
|
BLAKE2b-256 checksum How to use checksums |
93932431fbdce5e66150b18d75439c98ce6b17409130c61260d34dc2a24914ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / lix_open_cache-2.1.6-py3-none-any.whl
| Download URL | lix_open_cache-2.1.6-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
186412b1bc9c16749b8b1960cbe92aaa0169dd78b42f823cde639de2659500c5
|
|
BLAKE2b-256 checksum How to use checksums |
fd07b9e09cf8385bda4c194a39dc1e1c4cef8175caee5c8a73c30c06bf80a016
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for lix-open-cache 2.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.