UNPKG

simple-node-memory-cache

Version:

In-memory object cache written in typescript for Node that supports multiple eviction strategies.

43 lines (42 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var SimpleCache = /** @class */ (function () { function SimpleCache(maxObjectsInCache) { if (maxObjectsInCache === void 0) { maxObjectsInCache = 5; } this.cache = new Map(); this._maxObjectsInCache = maxObjectsInCache; } Object.defineProperty(SimpleCache.prototype, "maxObjectsInCache", { get: function () { return this._maxObjectsInCache; }, set: function (max) { this._maxObjectsInCache = max; }, enumerable: true, configurable: true }); SimpleCache.prototype.clear = function () { this.cache.clear(); }; SimpleCache.prototype.has = function (key) { return this.cache.has(key); }; SimpleCache.prototype.length = function () { return this.cache.size; }; SimpleCache.prototype.delete = function (key) { this.cache.delete(key); }; SimpleCache.prototype.entries = function () { return this.cache.entries(); }; SimpleCache.prototype.keys = function () { return this.cache.keys(); }; SimpleCache.prototype.values = function () { return this.cache.values(); }; return SimpleCache; }()); exports.SimpleCache = SimpleCache;