UNPKG

@kyve/core-beta

Version:

🚀 The base KYVE node implementation.

35 lines (34 loc) • 813 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MemoryCache = void 0; class MemoryCache { constructor() { this.name = "MemoryCache"; this.store = {}; } async init() { await this.drop(); } async put(key, value) { this.store[key] = value; } async get(key) { if (!this.store[key]) { throw new Error(`Entry with key ${key} not found`); } return this.store[key]; } async exists(key) { return !!this.store[key]; } async del(key) { if (!this.store[key]) { throw new Error(`Entry with key ${key} not found`); } delete this.store[key]; } async drop() { this.store = {}; } } exports.MemoryCache = MemoryCache;