UNPKG

ghost-cache

Version:

A lightweight auto-caching wrapper for fetch() and Axios with multi-storage support (localStorage, sessionStorage, IndexedDB, Redis)

22 lines (21 loc) 542 B
export class RedisAdapter { constructor(client) { if (!client) { throw new Error("A valid Redis client must be provided."); } this.client = client; } async getItem(key) { return this.client.get(key); } async setItem(key, value) { await this.client.set(key, value); } async removeItem(key) { await this.client.del(key); } async clear() { // WARNING: flushAll clears the entire Redis database! await this.client.flushAll(); } }