Skip to content

CacheManager

Sebastián Martínez edited this page Dec 29, 2025 · 1 revision

CacheManager

Categoría: Utilities | ⬅️ Volver al índice

CacheManager

class CacheManager {
    constructor(options?: CacheManagerOptions);
    set<T>(key: string, value: T, ttl?: number): void;
    get<T>(key: string): T | null;
    has(key: string): boolean;
    remove(key: string): void;
    clear(): void;
    async getOrCompute<T>(
        key: string,
        fn: () => Promise<T>,
        ttl?: number
    ): Promise<T>;
    invalidatePattern(pattern: string): void;
    getStats(): CacheStats;
}

function createCacheManager(options?: CacheManagerOptions): CacheManager;

interface CacheStats {
    hits: number;
    misses: number;
    hitRate: number;
    size: number;
    maxSize: number;
}

Enlaces Relacionados

Instalación

npm install bytekit

Importación

// Importación específica (recomendado)
import { CacheManager } from "bytekit/cachemanager";

// Importación desde el índice principal
import { CacheManager } from "bytekit";

💡 ¿Encontraste un error o tienes una sugerencia? Abre un issue o contribuye al proyecto.

Clone this wiki locally