mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:54:31 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { pruneMapToMaxSize } from "./map-size.js";
|
||||
|
||||
export type DedupeCache = {
|
||||
check: (key: string | undefined | null, now?: number) => boolean;
|
||||
clear: () => void;
|
||||
@@ -32,13 +34,7 @@ export function createDedupeCache(options: DedupeCacheOptions): DedupeCache {
|
||||
cache.clear();
|
||||
return;
|
||||
}
|
||||
while (cache.size > maxSize) {
|
||||
const oldestKey = cache.keys().next().value;
|
||||
if (!oldestKey) {
|
||||
break;
|
||||
}
|
||||
cache.delete(oldestKey);
|
||||
}
|
||||
pruneMapToMaxSize(cache, maxSize);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user