* Better debug log. * Set commands support lazy evaluation and content addition. * Unified in one tree and processing phase. * Supports Flux. * Fix evaluation of string variable as truthy. * Show invalid wildcards. * Better detection of installed UI. * Improved cache of results. * Works as a ComfyUI node. * Debug setting changed to debug level. * Fixes in variable use. * Added timing reporting. * Detection of more model types. * Installation script for requirements. * Extension metadata for A1111. * Lark grammar in separate file and cached. * Improved conditions for if command. * Avoid repeats in the processing of prompts. * Fix multiple loading of settings.
25 lines
696 B
Python
25 lines
696 B
Python
from collections import OrderedDict
|
|
from typing import Tuple
|
|
|
|
|
|
class PPPLRUCache:
|
|
|
|
ProcessInput = Tuple[int, str, str]
|
|
ProcessResult = Tuple[str, str]
|
|
|
|
def __init__(self, capacity: int):
|
|
self.cache = OrderedDict()
|
|
self.capacity = capacity
|
|
|
|
def get(self, key: ProcessInput) -> ProcessResult:
|
|
if key not in self.cache:
|
|
return None
|
|
self.cache.move_to_end(key)
|
|
return self.cache[key]
|
|
|
|
def put(self, key: ProcessInput, value: ProcessResult) -> None:
|
|
self.cache[key] = value
|
|
self.cache.move_to_end(key)
|
|
if len(self.cache) > self.capacity:
|
|
self.cache.popitem(last=False)
|