mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
75 lines (74 loc) • 2.07 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/masterstore.ts
var masterstore_exports = {};
__export(masterstore_exports, {
MasterStore: () => MasterStore,
masterstore: () => masterstore
});
module.exports = __toCommonJS(masterstore_exports);
var MasterStore = class {
#baseOptions = {};
#l1;
#l2;
#bus;
constructor(baseOptions = {}) {
this.#baseOptions = baseOptions;
}
/**
* Add a L1 layer to your store. This is usually a memory driver
* for fast access purposes.
*/
useL1Layer(driver) {
this.#l1 = driver;
return this;
}
/**
* Add a L2 layer to your store. This is usually something
* distributed like Redis, DynamoDB, Sql database, etc.
*/
useL2Layer(driver) {
this.#l2 = driver;
return this;
}
/**
* Add a bus to your store. It will be used to synchronize L1 layers between
* different instances of your application.
*/
useBus(bus) {
this.#bus = bus;
return this;
}
get entry() {
return {
options: this.#baseOptions,
l1: this.#l1,
l2: this.#l2,
bus: this.#bus
};
}
};
function masterstore(options) {
return new MasterStore(options);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MasterStore,
masterstore
});
//# sourceMappingURL=masterstore.cjs.map