ComfyUI Node

Text Cache

A Scrap of Paper That Survives Restarts

By babydjac·Created 7 months ago·Updated 5 months ago· 12
Text Cache
  • mode
  • value
key
value
namespacedefault

Most of the babydjacNODES pack wants your Grok API key. Text Cache is the odd one out: a tiny, fully local key/value store for strings that quietly persists on disk between runs. If you've ever wanted one workflow execution to remember a bit of text for the next - "what prompt did I end up using?", "which item is next in the rotation?", "don't make me retype this" - this is the node.

It's not a cache in the performance sense. There's no fast memory layer here. It's more like a sticky note: you write a string under a key, you read it back later, or you delete it. That's the whole job, and it does it without any API, any key, or any network.

How it works

The node keeps a JSON file (.apk_text_cache.json) in the pack's Utils folder inside your custom_nodes directory. Every set writes through to that file, and every get reads from it, so the data outlives ComfyUI restarts and even reboots.

Three operations, chosen by the mode dropdown:

  • get - read the string stored under key in the namespace. Missing key returns an empty string, not an error.
  • set - store the multiline value under key in namespace. It returns the value you stored, so it works inline in a chain.
  • delete - remove the key and return an empty string.

The namespace input (default "default") is your compartment. Keep a "session", a "batch", and a "results" namespace and they never collide.

A realistic pattern: set the prompt you settled on during an exploration run, then in your production workflow a get with the same key pulls it back without you copy-pasting across graphs. Or use it to hand one string from the first pass of a batch to a later pass.

The inputs that matter

Honestly, all three. mode and key are required; value only matters when you're setting; namespace is optional but you'll want it once you have more than a couple of keys.

One output, value, a STRING.

Install

Same as every node in this pack:

cd ComfyUI/custom_nodes
git clone https://github.com/babydjac/babydjacNODES
# restart ComfyUI

Or search "babydjacNODES" in ComfyUI Manager. No extra Python dependencies, no model files, no API key.

Where people get burned

  • Stale data. Because the store survives restarts, a get can return something you wrote hours ago. If a key you never set reads back as empty, that's the "not found" signal.
  • Namespace collisions across workflows. There's no per-workflow isolation. Two different graphs that both write to default with the same key will stomp each other. Use namespaces like you'd use directories.
  • Wiping on reinstall. The JSON lives inside the pack folder, so deleting or re-cloning the repo erases your cache. Treat it as scratch space, not as the one true source of a prompt.
  • Concurrent writers. If you run two ComfyUI instances against the same install, both writing the same file, you can lose a write. A single instance is the safe mode of operation.

It's unglamorous, but in a pack full of API calls this local sticky note is frequently the one node that just works.

CategorybabydjacNODES/Utils

Inputs (4)

NameTypeDefaultDescription
modeCHOICEget
keySTRING
valueoptSTRING
namespaceoptSTRINGdefault

Outputs (1)

NameTypeDescription
valueSTRING