Files
nodarium/app/src/lib/runtime/runtime-executor-cache.ts
Max Richter 5421349c79
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 4s
feat: migrate some more stuff to svelte-5, mainly app settings
2024-11-08 02:38:19 +01:00

20 lines
434 B
TypeScript

import { type SyncCache } from "@nodes/types";
export class MemoryRuntimeCache implements SyncCache {
private cache: [string, unknown][] = [];
size = 50;
get<T>(key: string): T | undefined {
return this.cache.find(([k]) => k === key)?.[1] as T;
}
set<T>(key: string, value: T): void {
this.cache.push([key, value]);
this.cache = this.cache.slice(-this.size);
}
clear(): void {
this.cache = [];
}
}