View as Markdown
State

Cache

A first-class durable key/value store for relays, flows, and webhook workflows. Register named caches once, then access them with `khotanCache(ctx, "name")` or `khotanData.cache("name")` for snapshots, cursors, and idempotency markers.

cache
source
snapshot
cache
reuse
workflow

Install

terminal
$ npx khotan add cache
import { cache } from "@/khotan/caches/cache";
export const cin7ProductsSnapshotCache = cache({
name: "cin7-products-snapshot",
scope: {
plug: "cin7",
resource: "products",
flow: "cin7-to-pollinate-products-relay",
},
ttl: "6h",
});

Highlights

  • Stores one latest value per cache/key pair in `khotan_cache_entries`
  • Optional TTL per cache definition
  • Scope metadata can point at a plug, resource, and flow for traceability
  • Works from flow, relay, catch, and pass workflow contexts

What to expect from add

Running npx khotan add cache scaffolds one or more files into your khotan runtime, React component directory, or app routes depending on the component. khotan may also prompt to install dependent components, npm packages, shadcn pieces, or Workflow integration when this component needs them.

Usage

Use the generated builder or UI inside your khotan setup and operational surfaces. For live runtime inspection, pair this component with the CLI and the built-in docs markdown routes.

Next steps