slm-cache

Solid

KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the same file, query result, or tool output is read more than once in a session.

AI & Automation 199 stars 34 forks Updated today AGPL-3.0

Install

View on GitHub

Quality Score: 88/100

Stars 20%
77
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# slm-cache — KV Cache for Repeated Reads (Surface B) ## Purpose 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. ## Tool: slm_cache_set ``` 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 ``` ### Return 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. ## Tool: slm_cache_get ``` slm_cache_get( key: str, # required — same key used in slm_cache_set ) -> dict ``` ### Return dict | Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on clean execution (including miss); `False` on i...

Details

Author
qualixar
Repository
qualixar/superlocalmemory
Created
5 months ago
Last Updated
today
Language
Python
License
AGPL-3.0

Similar Skills

Semantically similar based on skill content — not just same category