From SuperLocalMemory
Provides a KV cache (slm_cache_get/set) to avoid re-reading files, query results, or tool outputs within a session. Standard cache-aside pattern with TTL support.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superlocalmemory:slm-cacheWhen to use
cache file, avoid re-reading, repeated read, cache result, cache tool output, save re-read, reuse across session, cache check, cache hit, cache miss
This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
When the same file, query result, or expensive tool output is needed more than once in a session, fetching it again wastes tokens and time. `slm_cache_set` stores a result under a stable key; `slm_cache_get` retrieves it on subsequent calls. The cache is agent-scoped (automatically namespaced by tenant/agent ID), TTL-bounded, and fail-open.
When the same file, query result, or expensive tool output is needed more than once in a session, fetching it again wastes tokens and time. slm_cache_set stores a result under a stable key; slm_cache_get retrieves it on subsequent calls. The cache is agent-scoped (automatically namespaced by tenant/agent ID), TTL-bounded, and fail-open.
This is an agent-routed cache — it caches results the agent explicitly routes through SLM. It cannot cache Claude conversation turns.
slm_cache_set(
key: str, # required — cache key (max 512 chars)
value: str, # required — value to store (max 1 MB)
ttl_seconds: int = 86400, # time-to-live in seconds (default 24 h)
) -> dict
| Key | Type | Meaning |
|---|---|---|
ok | bool | True on success; False on validation error or internal error |
stored | bool | True when the value was written to the cache |
note | str | None | Error detail or None on success |
Keys are SHA-256-hashed internally per agent so they do not collide across agents. The raw key string you supply is the only handle you need.
slm_cache_get(
key: str, # required — same key used in slm_cache_set
) -> dict
| Key | Type | Meaning |
|---|---|---|
ok | bool | True on clean execution (including miss); False on internal error |
hit | bool | True when the key exists and has not expired |
value | str | None | The stored value on a hit; None on miss |
note | str | None | Error detail or None |
A miss returns {"ok": true, "hit": false, "value": null, "note": null}. ok: false means something went wrong internally but the miss behaviour is the same — treat both as a cache miss and proceed with the real fetch.
Always check the cache first, then fill on miss:
# 1. Check cache
cached = await slm_cache_get(key="file:/absolute/path/to/config.json")
if cached["hit"]:
content = cached["value"]
else:
# 2. Expensive operation (file read, search, API call)
content = read_file("/absolute/path/to/config.json")
# 3. Store for the rest of the session
await slm_cache_set(
key="file:/absolute/path/to/config.json",
value=content,
ttl_seconds=3600, # 1 h — adjust to data volatility
)
# 4. Use content
Use a stable, human-readable prefix so keys are recognisable in stats and won't collide accidentally:
| Content type | Suggested prefix | Example |
|---|---|---|
| File read | file: | file:/repo/src/config.py |
| Search result | search: | search:recall:session_init_context |
| Tool output | tool: | tool:build_code_graph:/repo |
| External fetch | url: | url:https://api.example.com/v1/data |
Key length cap: 512 characters. Keys longer than that are rejected (ok: false).
Cache when:
Do NOT cache:
ccr_id values (CCR already handles its own storage).Neither tool raises an exception. On any internal error:
slm_cache_get returns {"ok": false, "hit": false, "value": null, ...} — treat as a miss and proceed with the real fetch.slm_cache_set returns {"ok": false, "stored": false, ...} — log the note if useful, but continue; the value is still available in memory this step.Never block a task on a cache failure.
| Data type | Suggested TTL |
|---|---|
| Static config / generated file | 86400 s (24 h — the default) |
| Session-specific tool output | 3600 s (1 h) |
| Rapidly changing API data | Do not cache, or 60–300 s |
Set ttl_seconds to match how long the data remains valid. After expiry slm_cache_get returns a miss automatically.
The slm cache subcommand exists but has known pre-existing parse-test failures. Prefer the MCP tools above. If you must use CLI:
slm cache status [--json] [--tenant default]
slm cache clear [--json] [--tenant default]
slm cache invalidate --tag <tag> [--json] [--tenant default]
slm cache ttl --set <seconds> [--semantic <seconds>] [--json] [--tenant default]
slm cache semantic on|off [--json] [--tenant default]
These subcommands control daemon-level cache settings. They do not read or write individual cache entries — use the MCP tools for that.
SuperLocalMemory v3.6.14 · Qualixar · AGPL-3.0-or-later
npx claudepluginhub qualixar/superlocalmemory --plugin superlocalmemoryIn-memory key-value store with TTL for ephemeral session and temporary data on Catalyst. Handles segment operations, string-only values, and TTL gotchas.
Caches LLM prompts and responses using Anthropic prompt caching, Redis response caching, and Cache Augmented Generation (CAG).
Implements in-memory and Redis caching for OpenRouter LLM API responses on deterministic requests to reduce costs and latency. Use for repeat queries or RAG systems.