mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 17:11:04 -07:00
32 lines
517 B
TypeScript
32 lines
517 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { LRUMap } from 'mnemonist';
|
|
|
|
export class LruCache<K, V> {
|
|
private cache: LRUMap<K, V>;
|
|
|
|
constructor(maxSize: number) {
|
|
this.cache = new LRUMap<K, V>(maxSize);
|
|
}
|
|
|
|
get(key: K): V | undefined {
|
|
return this.cache.get(key);
|
|
}
|
|
|
|
has(key: K): boolean {
|
|
return this.cache.has(key);
|
|
}
|
|
|
|
set(key: K, value: V): void {
|
|
this.cache.set(key, value);
|
|
}
|
|
|
|
clear(): void {
|
|
this.cache.clear();
|
|
}
|
|
}
|