UNPKG

simple-graphql

Version:

The simple way to generates GraphQL schemas and Sequelize models from your models definition.

45 lines 1.91 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LruCacheManager = void 0; const lru_map_1 = require("lru_map"); const SGCacheManager_1 = require("./SGCacheManager"); class LruCacheManager extends SGCacheManager_1.SGCacheManager { constructor(limit = 1000) { super(); this.cacheMap = new lru_map_1.LRUMap(limit); } get(key) { return __awaiter(this, void 0, void 0, function* () { return this.cacheMap.get(key); }); } set(key, value, expire) { return __awaiter(this, void 0, void 0, function* () { this.cacheMap.set(key, value); }); } del(pattern) { return __awaiter(this, void 0, void 0, function* () { const regExp = new RegExp(pattern.replace(/\./g, '.').replace(/\*/g, '.*').replace(/\?/g, '.')); let count = 0; for (let [key, value] of this.cacheMap) { if (regExp.test(key)) { this.cacheMap.delete(key); count = count + 1; } } return count; }); } } exports.LruCacheManager = LruCacheManager; //# sourceMappingURL=LruCacheManager.js.map