图像缓存丨轮转
Hold 99 images in memory, then dump them in one batch
- image
Saving every image as it comes out of the sampler is wasteful when you're running a batch you might throw half of away. ImageCache inverts that: it swallows images into an in-memory buffer, shows you a live preview of what's cached, and only writes them to disk once the buffer hits 99 images - at which point it dumps the whole batch and starts over. If you're doing a long generation run and only want the survivors, or you want one clean export instead of a thousand tiny files, this is the node.
It lives in ComfyUI-QING's image-processing category (display name 图像缓存丨轮转) and is an output node with no data outputs - its job is the caching, the preview, and the eventual save.
How it works. Each instance of the node gets a unique ID and its own buffer. Every run, it clones the incoming image into the cache (holding the tensor in memory, not on disk). When the buffer reaches 99, it saves the whole batch to disk - to a per-instance folder under output/image_cache_<instanceID>/ by default, or to your custom_path - and clears the buffer. It also generates previews so the node UI shows you exactly how many images are sitting in the buffer, and it does periodic TTL cleanup (30 minutes without activity) to stop abandoned instances from leaking memory.
The metadata boolean controls whether the saved PNGs carry generation metadata - worth knowing given how the ecosystem treats the workflow-in-the-PNG convention: leave it on if you want to drag the output back into ComfyUI later, off if you're producing clean delivery files. The filename_prefix (default ComfyUI) names the saved files.
The inputs that matter.
image- feed it from a sampler's decoded output (VAE Decode → here), or chain several caches for different pipeline stages.metadata- include generation metadata in saved PNGs (default false).filename_prefix- the saved filename prefix (defaultComfyUI).custom_path- where the batch lands. Leave empty for the default output folder.clear_cache- flip on to wipe this instance's buffer and previews immediately.
How to install. ComfyUI-QING installs as one pack - search "ComfyUI-QING" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart afterward. The README's clone URL drops an "H" (GAOSHI-QING) - use the URL above or Manager.
Troubleshooting. The single biggest gotcha is baked into the tooltip and easy to miss: nothing saves until the cache hits 99 images. The custom_path field explicitly warns "只有图像达到上限99张之后才会触发保存机制" - only after 99 does saving trigger. People wire this up, run ten images, and wonder where the files went. They're still in memory. If your run won't reach 99, this node isn't the right exporter for it. Second: the cache is per-instance and in-memory - restarting ComfyUI before the batch fills loses everything, and copy-pasting the node creates a fresh buffer. Third: the preview shows cached count as a sanity check, but there's no manual "flush now" trigger - the only manual control is clear_cache, which discards rather than saves.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| metadata | BOOLEAN | false | 控制保存图像时是否包含生成元数据 |
| filename_prefix | STRING | ComfyUI | 保存图像的文件名前缀 |
| custom_path | STRING | 自定义保存路径,留空则使用ComfyUI默认output目录。注意:只有图像达到上限99张之后才会触发保存机制 | |
| clear_cache | BOOLEAN | false | 点击开启后将清空当前实例的所有缓存和预览图像 |
Outputs (0)
No outputs