64 docs indexed
All Redis key patterns, TTLs, hash structures, and Lua scripts used by obleth.
Redis is obleth's hot cache and the real-time token budget store. All Redis data is derivable from Postgres and can be rebuilt on cache miss.
| Key pattern | Type | TTL | Contents |
|---|---|---|---|
obleth:key:{sha256_hex} | String | 300s | JSON blob of ResolvedKey (tenant, weight, group, quotas) |
obleth:model:{model_name} | String | 300s | JSON blob of model config |
obleth:mcp:{mcp_name} | String | 300s | JSON blob of MCP server config |
obleth:budget:{tenant_uuid} | Hash | sliding | tokens (remaining this window), ts (window start timestamp ms) |
obleth:term_usage:{tenant_uuid} | Hash | period-scoped | Cumulative tokens and cost used in the current term-budget period |
obleth:cache:{sha256_of_prompt} | String | model-configured TTL | Cached response body |
{
"key_id": "661f9500-...",
"tenant_id": "550e8400-...",
"tenant_name": "chatbot",
"weight": 100,
"tokens_per_minute": 50000,
"max_in_flight": null,
"fairshare_group": "default",
"group_weight": 100,
"disabled": false
}
The hot path reads only this blob; it carries everything fairshare admission and budgeting need without a relational lookup.
The obleth:budget:{tenant_uuid} key is a Redis hash with two fields:
| Field | Type | Meaning |
|---|---|---|
tokens | integer | Tokens remaining in the current 60-second window |
ts | integer | Window start time (Unix milliseconds) |
On each request, a Lua script atomically:
ts; if so, resets tokens to tpm.tokens.-1 if exhausted.For tenants with a term budget, obleth:term_usage:{tenant_uuid} tracks cumulative tokens and cost for the current period (lifetime, monthly, or term). obleth reads it before admission and adds the reconciled true cost after each stream; when either configured cap is met the data plane returns 403.
obleth:cache:{sha256} stores the cached response for a chat completion request. The cache key is a SHA-256 of the canonicalized request body (model + messages + parameters). TTL is set per-model via cache_ttl_secs.
Channel: obleth:invalidate
When a config change is made via the Management API, obleth publishes a JSON invalidation message to this channel. All pods subscribed to the channel delete their moka and Redis cache entries for the affected resource.
{
"kind": "key",
"id": "sha256-hex-of-changed-key"
}
On a Redis miss for any obleth:key:* or obleth:model:* key, obleth:
This means a Redis restart does not require any manual action — the cache self-heals on first use.