Logos DX
    Preparing search index...

    Interface MemoizeSyncOptions<T>

    Construct a type with the properties of T except for those in type K.

    interface MemoizeSyncOptions<T extends Func<any>> {
        cleanupInterval?: number;
        generateKey?: (...args: Parameters<T>) => string;
        maxSize?: number;
        onError?: (error: Error, args: Parameters<T>) => void;
        shouldCache?: (...args: Parameters<T>) => boolean;
        ttl?: number;
        useWeakRef?: boolean;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    cleanupInterval?: number

    Background cleanup interval in ms. 0 to disable. Default: 60000

    generateKey?: (...args: Parameters<T>) => string

    Custom key generator from function arguments. Default: enhanced serializer

    maxSize?: number

    Maximum cache size. When exceeded, LRU items evicted. Default: 1000

    onError?: (error: Error, args: Parameters<T>) => void

    Error handler for key generation or execution failures

    shouldCache?: (...args: Parameters<T>) => boolean

    Pre-serialization check. Return false to bypass cache and execute the function directly. (Still deduped if deduplication is enabled separately)

    This is called BEFORE key generation/serialization. Use this for conditional caching based on request context or parameters.

    const fetcher = memoize(fetchData, {
    shouldCache: (url, opts) => !opts?.bustCache
    });
    ttl?: number

    Time to live in milliseconds. Default: 60000 (1 minute)

    useWeakRef?: boolean

    Use WeakRef for object values (allows GC). Default: false