mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
50 lines • 1.02 kB
JavaScript
// src/masterstore.ts
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);
}
export {
MasterStore,
masterstore
};
//# sourceMappingURL=masterstore.js.map