Skip to main content

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)

Source distribution for lix-open-cache 2.1.6
File Size Uploaded
lix_open_cache-2.1.6.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lix-open-cache 2.1.6
File Interpreter ABI Platform
lix_open_cache-2.1.6-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

2.1.6 This release

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page