UNPKG

@nasriya/cachify

Version:

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

35 lines (34 loc) 1.29 kB
import EvictConfig from "./evict/EvictConfig.js"; import IdleConfig from "./idle/IdleConfig.js"; import TTLConfig from "./ttl/TTLConfig.js"; class CacheConfig { #_ttl; #_eviction; #_idle; constructor(updateStatus, flavor) { this.#_ttl = new TTLConfig(updateStatus, { value: 300_000 }, flavor); this.#_eviction = new EvictConfig(updateStatus); this.#_idle = new IdleConfig(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; } } export default CacheConfig;