Nodes/Deforum Nodes/(deforum) Cache String
ComfyUI Node

(deforum) Cache String

Stash text across animation passes without a wire

By XmYx·Created 3 years ago·Updated 3 months ago· 198
(deforum) Cache String
    • STRING
    input_string
    cache_index0

    Animation graphs run in a loop, and loops hate plain wires - you can't route a value from "last pass" to "this pass" with a connection. (deforum) Cache String is the string-flavored half of the pack's cache family: write a text value into a numbered slot once, and the matching (deforum) Load Cached String node pulls it back out on a later pass. Same trick as Cache Latent / Load Cached Latent, but for text instead of tensors.

    What it's for

    Whenever a value must survive across executions of the graph, this is the mechanism. Concrete uses in a Deforum graph:

    • Passing a computed prompt forward. Some upstream node produces a string (a wildcard resolution, a filename, a schedule result); cache it, and the next iteration reads it back without re-deriving it.
    • Keeping state between frames - e.g., "the prompt used at frame 40" carried into the logic that decides frame 41.
    • Driving text-dependent nodes in a loop where a wire would just re-trigger the same computation.

    The cache lives in the pack's in-memory global storage, keyed by slot index - the same gs dict that holds the latent and image caches. The (deforum) Load Cached String sibling reads from the same slots, so the two nodes are really one store with two doors.

    The inputs and outputs that matter

    • input_string (STRING) - the text to stash.
    • cache_index (INT, 0–16, default 0) - the slot. Two independent strings need two different indexes; otherwise the later write clobbers the earlier one.

    Output:

    • STRING - the input passes straight through. Like every cache node in this pack, it's a passthrough with a side effect: the value you see is the value that got stored.

    Installing this pack

    Part of Deforum Nodes by XmYx. ComfyUI Manager: search Deforum Nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/XmYx/deforum-comfy-nodes
    

    Restart and let install.py do the first-install heavy lifting (deforum-studio backend from GitHub, scientific-Python stack, numpy pinned below 2.0, Python 3.10 required). For a node this small the install is overkill, but the pack is all-or-nothing.

    Common issues

    • The Load node returns "None" as a string. When a slot hasn't been written yet, the loader returns the string "None" - note that's a literal string, not an empty one. Don't be confused if you see it in a text box on the first pass.
    • Values overwritten by another branch. Every node writing to cache_index 0 shares the same slot. If two strings fight, give them different indexes.
    • Cache doesn't survive a restart. It's in-memory only. Close ComfyUI and the slots are empty - that's why fresh runs start with the loader returning "None".
    • Forgetting the reader. A cache write with no matching Load Cached String is harmless but useless. If nothing ever reads the slot, the node is doing nothing.
    Categorydeforum/cache

    Inputs (2)

    NameTypeDefaultDescription
    input_stringSTRING
    cache_indexINT00–16

    Outputs (1)

    NameTypeDescription
    STRINGSTRING