SCACHE.CREATE
SCACHE.CREATE namespace dimensions [METRIC cosine | l2 | ip] [THRESHOLD similarity]
- Group
- Semantic cache
- Complexity
- O(1)
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- write, slow
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- Performance and Scale
- On-Premise
- requires the semantic-cache license feature
The semantic cache returns a cached LLM response when a new query embedding is similar enough to one you stored, so paraphrased requests can hit. Your application computes the embeddings. SCACHE.CREATE creates a namespace for embeddings of exactly
dimensions values (1 to 65536).
Options
Section titled “Options”| Option | Effect |
|---|---|
METRIC cosine |
Cosine similarity (the default). |
METRIC l2 |
Euclidean distance, turned into a score that is 1 for identical vectors and falls toward 0 as the distance grows. |
METRIC ip |
Inner product. Use it with normalized embeddings. |
THRESHOLD similarity |
Minimum similarity, from 0.0 to 1.0, for SCACHE.GET to count a match as a hit. Default 0.85. Change it later with SCACHE.THRESHOLD. |
Option names and metric names are case-insensitive.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Namespace created | Simple string OK |
Same |
Errors:
ERR invalid dimensions (must be 1-65536)ifdimensionsis not an integer in that range.ERR unknown metric, use cosine|l2|ipfor any other metric.ERR threshold must be 0.0-1.0if the threshold is out of range or not a number.ERR unknown option 'name'for an option other thanMETRICandTHRESHOLD, andERR syntax errorif an option has no value.ERR namespace already exists or limit reachedif the namespace exists, or the server already holds its maximum number of semantic cache namespaces (max_namespacesunder[scache]).ERR wrong number of arguments for 'scache.create' commandif the argument count is wrong.NOLICENSE semantic-cache requires a HotKV license. Contact sales@hotkv.comif your license does not include thesemantic-cachefeature.
Examples
Section titled “Examples”127.0.0.1:6379> SCACHE.CREATE llm_cache 1536 METRIC cosine THRESHOLD 0.92OK127.0.0.1:6379> SCACHE.CREATE small 3OK127.0.0.1:6379> SCACHE.CREATE bad 0(error) ERR invalid dimensions (must be 1-65536)Compatibility
Section titled “Compatibility”HotKV-only command. Redis and Valkey have no equivalent.
See also
Section titled “See also”SCACHE.SET, SCACHE.GET, SCACHE.STATS, SCACHE.FLUSH, SCACHE.DROP, SCACHE.LIST, SCACHE.THRESHOLD, AI features guide
Was this page helpful?
Thanks for the feedback.