19 lines
411 B
TypeScript
19 lines
411 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);
|
|
}
|
|
} |