node-ts-cache-storage-memory
Version:
Memory storage module for node-ts-cache
20 lines (14 loc) • 461 B
text/typescript
import { ICacheItem, IStorage } from "node-ts-cache"
export class MemoryStorage implements IStorage {
private memCache: any = {}
constructor() {}
public async getItem(key: string): Promise<ICacheItem | undefined> {
return this.memCache[key]
}
public async setItem(key: string, content: any): Promise<void> {
this.memCache[key] = content
}
public async clear(): Promise<void> {
this.memCache = {}
}
}