@adcp/client API Reference - v3.3.3
    Preparing search index...

    Class MemoryStorage<T>

    In-memory storage implementation with TTL support

    This is the default storage used when no external storage is configured. Features:

    • TTL support with automatic cleanup
    • Pattern matching
    • Batch operations
    • Memory-efficient (garbage collection of expired items)
    const storage = new MemoryStorage<string>();
    await storage.set('key', 'value', 60); // TTL of 60 seconds
    const value = await storage.get('key');

    Type Parameters

    • T

    Implements

    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • options: { cleanupIntervalMs?: number; maxItems?: number; autoCleanup?: boolean } = {}
        • OptionalcleanupIntervalMs?: number

          How often to clean up expired items (ms), default 5 minutes

        • OptionalmaxItems?: number

          Maximum items to store before forcing cleanup, default 10000

        • OptionalautoCleanup?: boolean

          Whether to enable automatic cleanup, default true

      Returns MemoryStorage<T>

    Methods

    • Set a value with optional TTL

      Parameters

      • key: string

        Storage key

      • value: T

        Value to store

      • Optionalttl: number

        Time to live in seconds (optional)

      Returns Promise<void>

    • Get storage statistics

      Returns {
          totalItems: number;
          expiredItems: number;
          memoryUsage: number;
          lastCleanup: number;
          oldestItem?: number;
          newestItem?: number;
      }