UNPKG

desi-mongoose

Version:

A fun and intuitive MongoDB ODM for Node.js with a Hinglish twist

26 lines (25 loc) 666 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DesiCache = void 0; class DesiCache { static rakh(key, value, customTtl) { this.cache.set(key, { value, expiry: Date.now() + (customTtl || this.ttl) }); } static nikaal(key) { const item = this.cache.get(key); if (item && item.expiry > Date.now()) { return item.value; } this.cache.delete(key); return null; } static saafKaro() { this.cache.clear(); } } exports.DesiCache = DesiCache; DesiCache.cache = new Map(); DesiCache.ttl = 60000; // 1 minute default