All checks were successful
Pull Request CI / Merge Check (pull_request) Successful in 3m44s
29 lines
620 B
TypeScript
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;
|
|
}
|
|
} |