面试题答案
一键面试class CacheSystem<T> {
private cache: { [key: string]: T } = {};
// 添加数据方法
addData(key: string, value: T): void {
this.cache[key] = value;
}
// 获取数据方法
getData(key: string): T | undefined {
return this.cache[key];
}
}