IronFlowDocs

cache_get

Retrieve a value from the cache (memory or file-based).

Parameters

keystringrequired
Cache key to look up. Supports ${ctx.key} interpolation.
output_keystringdefault "cached_value"
Context key where the retrieved value is stored.
backendstringdefault "memory"
Storage backend: "memory" (process-global bounded cache) or "file" (JSON files on disk).
cache_dirstringdefault IRONFLOW_CACHE_DIR / ".ironflow_cache"
Directory for file-based cache entries. Only used when backend is "file". Per-node value overrides the env var.

Expired entries are automatically removed on access (from both memory and file backends).

cache_get and cache_set apply the same interpolation rules to key, so a value stored with key = "llm:${ctx.prompt_hash}" can be read back with the same expression. The interpolated key is also returned by cache_set as cache_key.

Context Output

  • <output_key> (default cached_value) — the cached value, or null if not found / expired.
  • cache_hittrue if a valid (non-expired) entry was found, false otherwise.

Example

Memory backend

local flow = Flow.new("read_from_memory_cache")

flow:step("lookup", nodes.cache_get({
    key = "user_token:${ctx.user_id}",
    output_key = "token",
    backend = "memory"
}))

flow:step("done", nodes.log({
    message = "Hit: ${ctx.cache_hit}, Value: ${ctx.token}"
})):depends_on("lookup")

return flow

Environment

  • IRONFLOW_CACHE_MAX_ENTRIES controls the process-global memory backend size. Default: 10000.
  • IRONFLOW_CACHE_DIR controls the default file backend directory when cache_dir is not set. Default: .ironflow_cache.

File backend

local flow = Flow.new("read_from_file_cache")

flow:step("lookup", nodes.cache_get({
    key = "${ctx.user_id}_token",
    output_key = "token",
    backend = "file",
    cache_dir = "/tmp/my_cache"
}))

flow:step("done", nodes.log({
    message = "Hit: ${ctx.cache_hit}, Value: ${ctx.token}"
})):depends_on("lookup")

return flow

IronFlow documentation

Find the next step

Type a keyword to search the documentation.

to move · Enter to open · Esc to close