mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-22 05:02:11 -03:00
project migration to typescript
Project migration to typescript
This commit is contained in:
32
src/ImageCache.ts
Normal file
32
src/ImageCache.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {createModuleLogger} from "./utils/LoggerUtils.js";
|
||||
import type { ImageDataPixel } from './types';
|
||||
|
||||
const log = createModuleLogger('ImageCache');
|
||||
|
||||
export class ImageCache {
|
||||
private cache: Map<string, ImageDataPixel>;
|
||||
|
||||
constructor() {
|
||||
this.cache = new Map();
|
||||
}
|
||||
|
||||
set(key: string, imageData: ImageDataPixel): void {
|
||||
log.info("Caching image data for key:", key);
|
||||
this.cache.set(key, imageData);
|
||||
}
|
||||
|
||||
get(key: string): ImageDataPixel | undefined {
|
||||
const data = this.cache.get(key);
|
||||
log.debug("Retrieved cached data for key:", key, !!data);
|
||||
return data;
|
||||
}
|
||||
|
||||
has(key: string): boolean {
|
||||
return this.cache.has(key);
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
log.info("Clearing image cache");
|
||||
this.cache.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user