Stone.js API
    Preparing search index...

    The agnostic cache store contract.

    A single backend (memory, Redis, a provider KV) implements it; application code depends only on this interface, so switching or mixing stores is configuration, not code. Values are structured (serialized by drivers that need it); TTLs are in seconds.

    interface CacheStore {
        add: <T = unknown>(
            key: string,
            value: T,
            options?: CacheSetOptions,
        ) => Promise<boolean>;
        clear: () => Promise<void>;
        decrement: (key: string, amount?: number) => Promise<number>;
        delete: (key: string) => Promise<boolean>;
        get: <T = unknown>(key: string) => Promise<T>;
        has: (key: string) => Promise<boolean>;
        increment: (key: string, amount?: number) => Promise<number>;
        invalidateTags: (tags: string[]) => Promise<void>;
        name: string;
        pull: <T = unknown>(key: string) => Promise<T>;
        remember: <T = unknown>(
            key: string,
            factory: () => T | Promise<T>,
            options?: CacheSetOptions,
        ) => Promise<T>;
        set: <T = unknown>(
            key: string,
            value: T,
            options?: CacheSetOptions,
        ) => Promise<void>;
    }

    Implemented by

    Index
    add: <T = unknown>(
        key: string,
        value: T,
        options?: CacheSetOptions,
    ) => Promise<boolean>

    Write only if the key is absent. Resolves to whether it was written.

    clear: () => Promise<void>

    Remove everything from the store.

    decrement: (key: string, amount?: number) => Promise<number>

    Atomically decrement a numeric value (created at 0 when absent).

    delete: (key: string) => Promise<boolean>

    Delete a key. Resolves to whether something was removed.

    get: <T = unknown>(key: string) => Promise<T>

    Read a value; undefined when absent or expired.

    has: (key: string) => Promise<boolean>

    Whether a (non-expired) value exists.

    increment: (key: string, amount?: number) => Promise<number>

    Atomically increment a numeric value (created at 0 when absent).

    invalidateTags: (tags: string[]) => Promise<void>

    Invalidate every key associated with any of the given tags.

    name: string

    A human-readable store name (e.g. 'memory', 'redis').

    pull: <T = unknown>(key: string) => Promise<T>

    Read and delete in one step.

    remember: <T = unknown>(
        key: string,
        factory: () => T | Promise<T>,
        options?: CacheSetOptions,
    ) => Promise<T>

    Return the cached value, or compute it with factory, store it, and return it (cache-aside). Concurrent calls for the same key share a single factory execution (stampede protection).

    set: <T = unknown>(
        key: string,
        value: T,
        options?: CacheSetOptions,
    ) => Promise<void>

    Write a value with optional TTL/tags.