UNPKG

@nasriya/cachify

Version:

A lightweight, extensible in-memory caching library for storing anything, with built-in TTL and customizable cache types.

49 lines (48 loc) 1.55 kB
import CachifyClient from "./client.js"; export class Cachify extends CachifyClient { /** * Retrieves the current debug mode status for the cache system. * * @returns {boolean} `true` if the debug mode is enabled, `false` otherwise. * @since v1.0.0 */ get debug() { return process.env.CACHIFY_DEBUG === 'true'; } /** * Sets the debug mode for the cache system. * * If the value is `true`, the cache system will log additional information about its operations. * If the value is `false`, the cache system will not log any additional information. * * @param {boolean} value - The value to set the debug mode to. * @throws {TypeError} Throws if the provided value is not a boolean. * @since v1.0.0 */ set debug(value) { if (typeof value !== 'boolean') { throw new TypeError('The provided value must be a boolean.'); } process.env.CACHIFY_DEBUG = value ? 'true' : 'false'; } /** * Creates a new instance of the CachifyClient class. * * @returns {CachifyClient} A new instance of the CachifyClient class. * @since v1.0.0 */ createClient() { return Cachify.createClient(); } /** * Creates a new instance of the CachifyClient class. * * @returns {CachifyClient} A new instance of the CachifyClient class. * @since v1.0.0 */ static createClient() { return new CachifyClient(); } } const cachify = new Cachify(); export default cachify;