@smartip/js
Version:
SmartIP.io Official Javascript Library (Typescript)
62 lines • 2.12 kB
JavaScript
;
/*
* Copyright 2019 SmartIP.io (https://smartip.io).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var LRUCache = require("lru-cache");
var InternalCache = /** @class */ (function () {
function InternalCache(maximumSize, expireSec) {
if (maximumSize === void 0) { maximumSize = typeof window !== 'undefined' ? 16 : 2048; }
if (expireSec === void 0) { expireSec = 86400 * 1000; }
var options = {
max: maximumSize,
maxAge: expireSec
};
this.cache = new LRUCache(options);
}
InternalCache.prototype.get = function (key) {
return this.cache.get(key);
};
InternalCache.prototype.flush = function (key) {
this.cache.del(key);
};
InternalCache.prototype.flushAll = function () {
this.cache.reset();
};
InternalCache.prototype.put = function (key, data) {
this.cache.set(key, data);
};
return InternalCache;
}());
exports.InternalCache = InternalCache;
var NoCache = /** @class */ (function () {
function NoCache() {
}
NoCache.prototype.get = function (key) {
return undefined;
};
NoCache.prototype.flush = function (key) {
// nothing to do
};
NoCache.prototype.flushAll = function () {
// nothing to do
};
NoCache.prototype.put = function (key, data) {
// nothing to do
};
return NoCache;
}());
exports.NoCache = NoCache;
//# sourceMappingURL=cache.js.map