/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
packages/js/src/cache/in-memory-cache.ts
37 строк
652 B
Paweł Tymczuk
feat(js): inbox sdk manage pagination state in cache (#6206)
05 авг 2024, 13:39
Не верифицирован
05 авг 2024, 13:39
508a6a9
Код
Авторство
О чём код?
import type { Cache } from './types'; export class InMemoryCache<T> implements Cache<T> { #cache: Map<string, T>; constructor() { this.#cache = new Map(); } get(key: string): T | undefined { return this.#cache.get(key); } getValues(): T[] { return Array.from(this.#cache.values()); } entries(): [string, T][] { return Array.from(this.#cache.entries()); } keys(): string[] { return Array.from(this.#cache.keys()); } set(key: string, value: T): void { this.#cache.set(key, value); } remove(key: string): void { this.#cache.delete(key); } clear(): void { this.#cache.clear(); } }