mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-11 12:17:45 +08:00
fix: follow ProxiedSingleton pattern for Caching class
Add Caching as a nested class inside ComfyAPI_latest inheriting from ProxiedSingleton with async instance methods, matching the Execution and NodeReplacement patterns. Retains standalone Caching class for direct import convenience. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
01705f5452
commit
1e971fdc87
@ -25,6 +25,7 @@ class ComfyAPI_latest(ComfyAPIBase):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.node_replacement = self.NodeReplacement()
|
self.node_replacement = self.NodeReplacement()
|
||||||
self.execution = self.Execution()
|
self.execution = self.Execution()
|
||||||
|
self.caching = self.Caching()
|
||||||
|
|
||||||
class NodeReplacement(ProxiedSingleton):
|
class NodeReplacement(ProxiedSingleton):
|
||||||
async def register(self, node_replace: io.NodeReplace) -> None:
|
async def register(self, node_replace: io.NodeReplace) -> None:
|
||||||
@ -84,6 +85,20 @@ class ComfyAPI_latest(ComfyAPIBase):
|
|||||||
image=to_display,
|
image=to_display,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Caching(ProxiedSingleton):
|
||||||
|
"""External cache provider API for sharing cached node outputs."""
|
||||||
|
from ._caching import CacheProvider, CacheContext, CacheValue
|
||||||
|
|
||||||
|
async def register_provider(self, provider: "ComfyAPI_latest.Caching.CacheProvider") -> None:
|
||||||
|
"""Register an external cache provider."""
|
||||||
|
from comfy_execution.cache_provider import register_cache_provider
|
||||||
|
register_cache_provider(provider)
|
||||||
|
|
||||||
|
async def unregister_provider(self, provider: "ComfyAPI_latest.Caching.CacheProvider") -> None:
|
||||||
|
"""Unregister an external cache provider."""
|
||||||
|
from comfy_execution.cache_provider import unregister_cache_provider
|
||||||
|
unregister_cache_provider(provider)
|
||||||
|
|
||||||
class ComfyExtension(ABC):
|
class ComfyExtension(ABC):
|
||||||
async def on_load(self) -> None:
|
async def on_load(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user