Files
milsim-site-v4/api/src/services/cache/cache.ts
ajdj100 0cc327a9c4
All checks were successful
Pull Request CI / Merge Check (pull_request) Successful in 3m44s
Added cache busting option for devs
2026-03-08 10:34:29 -04:00

29 lines
620 B
TypeScript

export class CacheService<Key, Value> {
private cacheMap: Map<Key, Value>
constructor() {
this.cacheMap = new Map<Key, Value>();
}
public Get(key: Key): Value {
return this.cacheMap.get(key)
}
public Set(key: Key, value: Value) {
this.cacheMap.set(key, value);
}
public Invalidate(key: Key): boolean {
return this.cacheMap.delete(key);
}
public Size(): number {
return this.cacheMap.size;
}
public Clear(): number {
const priorSize = this.cacheMap.size;
this.cacheMap.clear();
return priorSize;
}
}