@adcp/sdk API Reference - v14.3.0
    Preparing search index...

    Interface AtomicTakeStorage<T>

    Storage that can atomically consume a value.

    take() MUST read and delete the value as one indivisible operation. A get() followed by delete() is not equivalent: two replicas could both read the same continuation and advance one seller task twice.

    interface AtomicTakeStorage<T> {
        get(key: string): Promise<T | undefined>;
        set(key: string, value: T, ttl?: number): Promise<void>;
        delete(key: string): Promise<void>;
        has(key: string): Promise<boolean>;
        clear?(): Promise<void>;
        keys?(): Promise<string[]>;
        size?(): Promise<number>;
        putIfAbsent(key: string, value: T, ttl?: number): Promise<boolean>;
        take(key: string): Promise<T | undefined>;
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Implemented by

    Index
    • Get a value by key

      Parameters

      • key: string

        Storage key

      Returns Promise<T | undefined>

      Value or undefined if not found

    • 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>

    • Atomically create a value only when the key is absent or expired.

      Parameters

      • key: string
      • value: T
      • Optionalttl: number

      Returns Promise<boolean>