Overview
SIMPLE_CACHE_QUICK provides the simplest possible caching with the
powerful remember pattern - get from cache or compute and store automatically.
For full control including Redis support, use SIMPLE_CACHE directly.
Quick Start
local
cache: SIMPLE_CACHE_QUICK
value: detachable STRING
do
create cache.make
cache.set ("user:123", user_json)
value := cache.get ("user:123")
cache.set_for ("session", token, 3600)
value := cache.remember ("expensive_key", agent compute_value)
value := cache.remember_for ("data", 300, agent fetch_data)
cache.increment ("page_views")
cache.increment_by ("score", 10)
print (cache.stats)
end
The Remember Pattern
This is the most useful caching pattern - eliminates boilerplate cache checking:
value := cache.get ("key")
if value = Void then
value := expensive_computation
cache.set ("key", value)
end
value := cache.remember ("key", agent expensive_computation)
API Reference
Basic Operations
| Feature | Description |
get (key) | Get cached value |
set (key, value) | Store value |
set_for (key, value, ttl) | Store with TTL in seconds |
delete (key) | Remove entry |
has (key) | Check if key exists |
clear | Clear all entries |
Remember Pattern
| Feature | Description |
remember (key, agent) | Get or compute and cache |
remember_for (key, ttl, agent) | Get or compute with TTL |
Counters
| Feature | Description |
increment (key) | Increment by 1 |
increment_by (key, n) | Increment by n |
decrement (key) | Decrement by 1 |
Statistics
| Feature | Description |
stats | Formatted statistics string |
hit_rate | Cache hit rate (0.0-1.0) |
count | Number of cached entries |