@nasriya/cachify
Version:
A lightweight, extensible in-memory caching library for storing anything, with built-in TTL and customizable cache types.
83 lines (82 loc) • 2.93 kB
JavaScript
import ExtEngines from "./api/engines/ext.engines.js";
import ExtPersistenceManager from "./api/persistence/ext.persistence.manager.js";
import Engines from "./core/engines/Engines.js";
import EnginesProxy from "./core/engines/EnginesProxy.js";
import Events from "./core/events/events.js";
import FilesCacheManager from "./core/flavors/files/files.manager.js";
import KVsCacheManager from "./core/flavors/kvs/kvs.manager.js";
import PersistenceManager from "./core/persistence/persistence.manager.js";
import PersistenceProxy from "./core/persistence/proxy.js";
export class CachifyClient {
kvs: new KVsCacheManager({
enginesProxy: this.
persistenceProxy: this.
eventsManager: this.
}),
files: new FilesCacheManager({
enginesProxy: this.
persistenceProxy: this.
eventsManager: this.
})
};
/**
* Access the engines manager.
*
* The engines manager is used to configure and access the engines
* used by the cache system to store records.
*
* @since v1.0.0
*/
engines = new ExtEngines(this.
/**
* Retrieves the events broker for the cache system.
*
* The events broker is used to emit and listen to cache-related events.
*
* @since v1.0.0
*/
get events() { return this.
/**
* Access the key-value cache manager.
* @returns {KVCacheManager}
* @since v1.0.0
*/
get kvs() { return this.
/**
* Access the file cache manager.
* @returns {FileCacheManager}
* @since v1.0.0
*/
get files() { return this.
/**
*
* @since v1.0.0
*/
persistence = new ExtPersistenceManager(this.
/**
* Clears the cache for the specified scope or for all scopes if no scope is provided.
*
* This method delegates the clearing operation to the `clear` method of all cache managers.
*
* @param {string} [scope] - The scope for which to clear the cache. If not provided, clears all scopes.
* @since v1.0.0
*/
async clear(scope) {
// Call the `clear` method of all cache managers
await Promise.all([
this.
this.
/**
* TODO: Once other cache managers are implemented,
* call the `clear` method of each cache manager
*/
]);
}
}
export default CachifyClient;