Nodes/SP-Nodes/SP_CacheGet
ComfyUI Node

SP_CacheGet

Read a cached value without any risk of triggering a recompute

By bananasss00·Created 2 years ago·Updated 12 days ago· 20
SP_CacheGet
  • default_value
  • value
keydefault_key

Where SP_CacheAutoLoader and SP_CacheValue will compute and store a value the first time they see a new key, SP_CacheGet does neither - it's a pure read. Hand it a key, get back whatever's stored there, or a fallback you specify if nothing's there. The pack's description: "Gets a value from cache; returns a default if not found."

That distinction matters more than it looks. This node has no value input at all - there's nothing for it to compute or cache, which means it can never accidentally trigger the expensive upstream work that a caching node like SP_CacheAutoLoader might. It's the safe node to drop somewhere you want to consume a cached value without any risk of the node itself causing a slow recompute.

How it works

It reads the same shared cache namespace the rest of the SP_Cache family writes to - so whatever SP_CacheStore or SP_CacheValue wrote under a given key elsewhere in the graph (or in a previous run, if it made it to disk) is exactly what this node returns. If the key isn't found, it falls back to default_value instead of erroring, so a graph that reads a key before anything has populated it doesn't just crash.

Inputs and outputs

  • key (STRING, required, default default_key) - which cache entry to read.
  • default_value (optional, any type) - what to return if key isn't cached. Leave it unset and a miss presumably returns nothing meaningful, so it's worth wiring something sensible here for any graph that might run before the cache is populated.
  • Output: value - whatever was found, or the default.

Installing it

ComfyUI Manager - search "SP-Nodes", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/bananasss00/ComfyUI-SP-Nodes

then restart. No extra dependencies for this node.

Common issues

You get the default every time, even after caching something. Check the key string matches exactly - this is a straight string lookup, no normalization, so Default_Key and default_key are two different entries. Also worth checking where the value was written: if it was cached in-memory only by a node earlier in the same graph and this read happens on a later run after a ComfyUI restart, the memory cache is gone and only a disk-persisted entry (from SP_CacheAutoLoader or a manual SP_CachePersistence save) would still be there.

You wanted it to compute on a miss, not just return a default. That's not this node's job - for compute-if-missing behavior, use SP_CacheAutoLoader or SP_CacheValue instead. SP_CacheGet is deliberately read-only, which is exactly why it's the safer choice when you just need to consume a value someone else already cached.

CategorySP-Nodes/cache

Inputs (2)

NameTypeDefaultDescription
keySTRINGdefault_keyThe key of the value to retrieve from the cache.
default_valueopt*The value to return if the key is not found in the cache.

Outputs (1)

NameTypeDescription
value*