@webfaas/webfaas-core
Version:
WebFaaS Framework - Core
68 lines • 1.81 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModuleManagerCacheObjectItem = void 0;
/**
* manager Module Require Context Data
*/
class ModuleManagerCacheObjectItem {
constructor(name, version) {
this.createAccess = new Date().getTime();
this.lastAccess = new Date().getTime();
this.cacheObject = new Map();
this.hitCount = 0;
this.packageStoreCache = null;
this.manifest = null;
this.name = name;
this.version = version;
}
updateAccessMetrics() {
this.lastAccess = new Date().getTime();
this.hitCount++;
}
getName() {
return this.name;
}
getVersion() {
return this.version;
}
getCreateAccess() {
return this.createAccess;
}
getLastAccess() {
return this.lastAccess;
}
getHitCount() {
return this.hitCount;
}
setObjectToCache(key, obj) {
this.cacheObject.set(key, obj);
}
removeObjectFromCache(key) {
this.cacheObject.delete(key);
}
getObjectFromCache(key) {
this.updateAccessMetrics();
if (key) {
return this.cacheObject.get(key) || null;
}
else {
//access main module
return this.cacheObject.get("") || null;
}
}
getPackageStoreCache() {
this.updateAccessMetrics();
return this.packageStoreCache;
}
setPackageStoreCache(packageStoreCache) {
this.packageStoreCache = packageStoreCache;
}
getManifest() {
return this.manifest;
}
setManifest(manifest) {
this.manifest = manifest;
}
}
exports.ModuleManagerCacheObjectItem = ModuleManagerCacheObjectItem;
//# sourceMappingURL=ModuleManagerCacheObjectItem.js.map