Kernlift

Cache

Ten cache domains with their own TTLs, in memory or in Cloudflare KV, each clearable on its own.

Every request that touches payments, email, storage or AI reads the provider configuration from the admin config table. Those reads are cached per domain, with a TTL you set at /admin/config/cache. You can clear each domain separately when you have changed something and do not want to wait for its TTL to expire.

Before you begin

  • config.read to see the page, config.write to change a TTL or clear a domain. See Roles and permissions.
  • Memory is the default. Cloudflare KV is available only when the runtime has a CACHE binding. Redis is listed with an unavailable reason and is not connected to the cache layer.

Set it up

Choose a backend

Memory caches inside one process. On Workers, each isolate caches separately, and on Node each container does. KV is shared across instances. Unavailable backends remain visible with a reason. The runtime falls back to process memory if a configured backend is unavailable.

Set a TTL per domain

Each domain has its own default. With a short TTL on configuration, a provider change takes effect quickly. With a longer TTL on templates, content that rarely changes is read less often.

The save form accepts 1–86,400 seconds. Turn off Enabled to bypass caching for that domain. The TTL is retained for later use.

Clear a domain after a change

Saving a provider from /admin/config/* clears that domain, so your change takes effect without waiting for the TTL. Clear a domain by hand when you changed a row outside the console.

Domains and their defaults

DomainWhat it holdsDefault TTL
admin_configThe admin config table itself30s
auth_configAuth providers and options30s
email_configEmail provider settings30s
email_templateRendered email templates60s
payment_configPayment provider settings30s
storage_configObject storage settings30s
analytics_configAnalytics provider settings30s
newsletter_configNewsletter provider settings30s
ai_channel_snapshotThe channel list30s
ai_channel_resolvedScene → channel resolution15s

admin_config is the bootstrap domain. Every other domain reads its own policy through it, so it cannot read its policy from the table it caches. Its TTL comes from ADMIN_CONFIG_CACHE_TTL_MS, one of the few environment variables this project reads.

Policy

Prop

Type

To add another cache domain, update cacheDomains in cache-policy.ts. The admin page then shows its TTL setting and clear action.

Verify

  1. Open /admin/config/cache. Ten domains are listed with their TTLs.
  2. Change a payment setting at /admin/config/payment, then load a checkout. The new setting is in effect immediately, without the 30-second wait.
  3. Turn off Enabled for email_template and save. Template reads stop being cached.
  4. On a runtime without the CACHE binding, the KV option is shown with the reason it is unavailable.

Reference

Next steps