| Ocalt Query Language
Pricing Dashboard ocalt.com v1.0

Cache

In-memory key-value cache scoped to your namespace. Values survive across queries until they expire or are explicitly deleted.

VerbDescription
CACHE "value" AS "key"Store a value — never expires
CACHE "value" AS "key" ON "seconds"Store with TTL — integer seconds only
CACHE "key" SET ?valRetrieve by key — returns null if missing or expired
FLUSH "key"Delete a cache entry
EXPIRE "key" ON "seconds"Reset the TTL on an existing key
Syntax note: Store and retrieve use different forms — when AS is present, it is a write; when only SET is present, it is a read. There are no CACHE GET or CACHE SET forms.

Store and retrieve

CACHE "Engineering Magic" AS "greeting" AFTER CACHE "greeting" SET ?val AFTER EMIT ?val
Try it ›

Store with TTL

The TTL is in integer seconds. 1800 = 30 minutes.

CACHE "user_42" AS "session:abc123" ON "1800" AFTER CACHE "session:abc123" SET ?uid AFTER EMIT ?uid
Try it ›

Store any value — cast first

CACHE stores text. To cache objects or arrays, serialise with CAST AS "json" and deserialise with PARSE JSON.

QUERY "products" FROM "shop" SORT BY "sales" LIMIT 10 SET ?rows AFTER CAST ?rows AS "json" SET ?json_str AFTER CACHE ?json_str AS "top_products" ON "300" (* Read back *) CACHE "top_products" SET ?cached AFTER IF ?cached IS NOT NULL OPEN NEST PARSE JSON ?cached SET ?rows AFTER EMIT ?rows CLOSE NEST

Cache-aside pattern

Check cache first; fall back to source on miss; populate cache for next time.

CACHE "top_products" SET ?cached AFTER IF ?cached IS NOT NULL OPEN NEST PARSE JSON ?cached SET ?products AFTER EMIT ?products CLOSE NEST OR QUERY "products" FROM "shop" SORT BY "sales" LIMIT 10 SET ?fresh AFTER CAST ?fresh AS "json" SET ?json_str AFTER CACHE ?json_str AS "top_products" ON "300" AFTER EMIT ?fresh

FLUSH — delete a key

CACHE "greeting" AS "greet" AFTER FLUSH "greet" AFTER CACHE "greet" SET ?val AFTER EMIT ?val (* → null *)
Try it ›

EXPIRE — reset TTL on an existing key

EXPIRE "session:abc123" ON "3600" AFTER EMIT "Session TTL reset to 1 hour"

Rate limiter

(* 10 requests per 60 seconds per user *) CACHE "rate:" & !REQUEST(header:x-user-id) SET ?count AFTER IF ?count IS NULL OPEN NEST CACHE "1" AS "rate:" & !REQUEST(header:x-user-id) ON "60" CLOSE NEST OR IF ?count IS GREATER THAN OR EQUAL TO 10 OPEN NEST STATUS 429 AFTER EMIT "Rate limit exceeded" AFTER EXIT ALL CLOSE NEST OR CALCULATE "?count + 1" SET ?new_count AFTER CACHE ?new_count AS "rate:" & !REQUEST(header:x-user-id) ON "60"
FeatureCACHEREMEMBER
PersistenceExpires with TTL or on restartPermanent until FORGET
TTL supportYes — ON "seconds"No
Typical useSessions, rate limits, expensive computation resultsConfig, flags, counters, cursors