@adobe/data - v0.10.30
    Preparing search index...

    Interface BlobStore

    A blob store is a service that can efficiently store blobs across sessions and retrieve them using the browsers Cache api.

    interface BlobStore {
        _testGetBorrowCount(
            r:
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
        ): number;
        borrowUrl(
            r:
                | null
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
        ): Promise<null | string>;
        createRemoteBlobRef(
            url: string,
        ):
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string };
        flush(): Promise<void>;
        getBlob(
            r:
                | null
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
        ): Promise<null | Blob>;
        getRef(
            b: string | Blob,
        ): Promise<
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string },
        >;
        hasBlob(
            r:
                | null
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
        ): Promise<boolean>;
        releaseBlob(
            r:
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
        ): Promise<void>;
        returnUrl(url: null | string): void;
        withRemoteUrl(
            ref:
                | { remoteBlobRef: string }
                | { localBlobRef: string }
                | { localBlobRef: string; remoteBlobRef: string },
            url: string,
        ):
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string };
    }
    Index

    Methods

    • TEST ONLY: Gets the current borrow count for a blob reference. This should only be used in tests to verify reference counting behavior.

      Parameters

      • r:
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

        The blob reference to check

      Returns number

      The number of times the blob reference has been borrowed, or 0 if not borrowed

    • Do NOT use this directly, use useBorrowUrl hook instead as it will automatically return the url when the component unmounts.

      Parameters

      • r:
            | null
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

      Returns Promise<null | string>

    • Creates a new remote blob ref. The url must start with http. This should only be called if the remote content is persistent and immutable.

      Parameters

      • url: string

      Returns
          | { remoteBlobRef: string }
          | { localBlobRef: string }
          | { localBlobRef: string; remoteBlobRef: string }

    • Resolves once every deferred blob write has reached durable storage. Rejects if any deferred write failed. Call this before persisting any document that references local blob refs — it is the durability barrier that makes deferred writes safe.

      Returns Promise<void>

    • Gets a blob from the blob store or null if it is not available.

      Parameters

      • r:
            | null
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

      Returns Promise<null | Blob>

    • Stores a blob and returns a reference to it. Blob references are based upon the content and type of the Blob. If an equivalent blob is stored, an equivalent reference will be returned every time.

      The returned ref is readable immediately, but its durable (storage-tier) write is deferred off the critical path. Any layer that persists a document containing a local blob ref MUST await BlobStore.flush first, or the persisted ref may point at bytes that never reached storage and will not resolve after reload.

      Parameters

      • b: string | Blob

      Returns Promise<
          | { remoteBlobRef: string }
          | { localBlobRef: string }
          | { localBlobRef: string; remoteBlobRef: string },
      >

    • Checks if the blob is still available.

      Parameters

      • r:
            | null
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

      Returns Promise<boolean>

    • Removes a blob from the store.

      Parameters

      • r:
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

      Returns Promise<void>

    • Return a url that was previously borrowed from borrowUrl. Failure to do so may result in memory leaking.

      Parameters

      • url: null | string

        The url provided by borrowUrl.

      Returns void

    • Augments an existing local blob ref with a remote URL, producing a combined ref (same content identity, now also re-fetchable at the URL). The URL must start with http and MUST serve immutable content whose hash equals the ref's localBlobRef; the local fast-path and dedup identity are preserved.

      Parameters

      • ref:
            | { remoteBlobRef: string }
            | { localBlobRef: string }
            | { localBlobRef: string; remoteBlobRef: string }

        A local (or already-combined) blob ref.

      • url: string

        The persistent, immutable URL the same content is served from.

      Returns
          | { remoteBlobRef: string }
          | { localBlobRef: string }
          | { localBlobRef: string; remoteBlobRef: string }