Source: RedisVL SemanticCache user guide
The open-source RedisVL library's SemanticCache: cosine-distance thresholds, TTL with refresh-on-hit, tag/numeric filters for per-user scoping, and drop/clear APIs.
Contents
- What: official library documentation (RedisVL user guide, “Semantic caching for LLMs”)
- Publisher: Redis (RedisVL project)
- Date: accessed 2026-11-14 (living docs)
- Original: docs.redisvl.com LLM cache guide
Summary
RedisVL is Redis’s Python client for vector workloads. Its SemanticCache class is a self-hosted semantic cache on Redis 8+ or Redis Cloud, with a pluggable vectorizer (the guide uses redis/langcache-embed-v2).
Key claims
distance_thresholdis a maximum cosine distance on Redis’s 0-2 scale (0 = identical). Lower is stricter. The guide’s example uses 0.1 and shows a looser 0.5 matching more.- The right threshold depends on the embedding model, the input distribution and the business case; it is meant to be tuned.
ttl(seconds) expires entries; without it entries persist forever. By defaultcheck()refreshes the TTL of every matched entry (a sliding window), which can surprise you; turn it off withrefresh_ttl_on_hit=Falseat init orrefresh_ttl=Falseper check.filterable_fields(tag or numeric) are attached atstore()and applied atcheck()viafilter_expression, e.g. auser_idtag to keep users’ entries apart.- Entry IDs are a SHA-256 of prompt plus filters, so the same prompt under different filters is a separate entry.
drop(ids|keys)removes entries,clear()empties the cache,delete()also drops the index.