Nodes/SP-Nodes/SP_CacheCheck
ComfyUI Node

SP_CacheCheck

A boolean gate for whether a key is already cached

By bananasss00·Created 2 years ago·Updated 12 days ago· 20
SP_CacheCheck
    • is_cached
    keydefault_key

    Sometimes you don't want a node to silently reuse a cached value or silently recompute one - you want to know, right now, whether a given key is already cached, so you can branch the graph on it yourself. That's the entire job of SP_CacheCheck: hand it a key, get back a boolean. The pack's own description: "Returns True if the key is cached, otherwise False."

    It's the smallest node in this pack's cache family (alongside SP_CacheAutoLoader, SP_CacheGet, SP_CacheManager, SP_CachePersistence, SP_CacheStore, SP_CacheValue and SP_CompositeCacheKey), and it's deliberately dumb - no reading, no writing, just a lookup. That makes it the node to reach for when you want explicit control over the branch rather than letting SP_CacheAutoLoader or SP_CacheValue decide for you.

    How it works

    Under the hood this checks the same shared cache the rest of the SP_Cache nodes read and write - the key namespace is common across the family, so a key stored by SP_CacheStore or SP_CacheValue elsewhere in your graph is exactly what SP_CacheCheck will find. It doesn't touch memory-vs-disk semantics itself; it's just asking "does this key currently resolve to something."

    Inputs and outputs

    • key (STRING, required, default default_key) - the cache key to check for existence. That's the entire input surface.
    • Output: is_cached (BOOLEAN) - true if the key currently resolves to a cached value, false otherwise.

    Installing it

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

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

    then restart ComfyUI. No dependencies beyond the base pack.

    Putting it to use

    On its own this node just produces a boolean - you need something downstream that acts on it. The pack ships a few switch-style nodes (SimpleValueSwitch, EnumSwitch among them) that are the natural pairing: check is_cached, then route the graph toward "read the cached value" or "do the expensive work and store it" depending on the result. That's a more explicit, visible version of what SP_CacheAutoLoader does implicitly through lazy evaluation - useful when you want the branch to be something you can see in the graph rather than something happening inside one node.

    Common issues

    A key you expect to be cached comes back false. The usual causes: a typo in the key string (this is exact-string matching, not fuzzy), the cache having been cleared since (check with SP_CacheManager's view action), or ComfyUI having restarted since the value was cached in memory only, with nothing persisted to disk. If you need a cache to survive a restart, that's SP_CacheAutoLoader's job (it writes to disk automatically) or a manual SP_CachePersistence save_to_disk step - SP_CacheCheck itself has no opinion on persistence, it just reports what's there right now.

    CategorySP-Nodes/cache

    Inputs (1)

    NameTypeDefaultDescription
    keySTRINGdefault_keyThe key to check for existence in the cache.

    Outputs (1)

    NameTypeDescription
    is_cachedBOOLEAN