UNPKG

@nasriya/cachify

Version:

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

40 lines (39 loc) 1.6 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const EvictConfig_1 = __importDefault(require("./evict/EvictConfig")); const IdleConfig_1 = __importDefault(require("./idle/IdleConfig")); const TTLConfig_1 = __importDefault(require("./ttl/TTLConfig")); class CacheConfig { #_ttl; #_eviction; #_idle; constructor(updateStatus, flavor) { this.#_ttl = new TTLConfig_1.default(updateStatus, { value: 300_000 }, flavor); this.#_eviction = new EvictConfig_1.default(updateStatus); this.#_idle = new IdleConfig_1.default(updateStatus); } /** * Retrieves the TTL configuration for the cache. * The TTL configuration determines the behavior of expired records. * @returns {TTLConfig<F>} The TTL configuration. */ get ttl() { return this.#_ttl; } /** * Retrieves the eviction configuration for the cache. * The eviction configuration determines the policy for removing records * when the cache reaches its capacity. * @returns {EvictConfig} The eviction configuration. */ get eviction() { return this.#_eviction; } /** * Retrieves the idle configuration for the cache. * The idle configuration determines the behavior of the cache when it is not * accessed for a certain amount of time. * @returns {IdleConfig} The idle configuration. */ get idle() { return this.#_idle; } } exports.default = CacheConfig;