class CyCache { #data = new Map(); keyName = 'cy' maxSize = 1000; constructor(name: string) { this.keyName = name; } async get(key: string, cb: Function) { if (this.#data.size > this.maxSize) { this.#data.clear() } const k = this.keyName + '_' + key const temp = this.#data.get(k) if (temp) { return temp } const t = (await cb)(key) if (t !== null) { this.#data.set(k, t) } return t } setMaxSize(size: number) { this.maxSize = size; } clear() { this.#data.clear() } } export default CyCache