/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Datasource } from "#behavior/state/managed/Datasource.js"; import { StorageDriver, Transaction } from "@matter/general"; import { Val } from "@matter/protocol"; import { EndpointNumber } from "@matter/types"; import type { ClientCacheBuffer } from "./ClientCacheBuffer.js"; import type { LocalWriter } from "./LocalWriter.js"; import { RemoteWriteParticipant } from "./RemoteWriteParticipant.js"; import type { RemoteWriter } from "./RemoteWriter.js"; /** * The default implementation of {@link Datasource.ExternallyMutableStore}. * * This implements storage for attribute values for a single cluster loaded from peers. * * The peer is the only writer of these values. Its reports and its answers to our writes are settlements that enter * through one path, in one sequence: {@link externalSet} and {@link settleAccepted}. */ export declare class DatasourceCache implements Datasource.ExternallyMutableStore, RemoteWriteParticipant.Receiver { #private; initialValues?: Val.Struct; constructor(options: DatasourceCache.Options); get consumer(): Datasource.ExternallyMutableStore.Consumer | undefined; set consumer(consumer: Datasource.ExternallyMutableStore.Consumer | undefined); /** * Current values, preferring the live consumer over the seed snapshot, so cluster structure can rebuild from * up-to-date data while a behavior is active. */ get currentValues(): Val.Struct | undefined; set(transaction: Transaction, values: Val.Struct): Promise; settleAccepted(values: Val.Struct, epoch: number): Promise; externalSet(values: Val.StructMap): Promise; /** * Reclaim {@link initialValues} from the active datasource so the cache can be detached. Blocks * {@link externalSet} until a new {@link consumer} is assigned, preventing writes to the released datasource. */ reclaimValues(): void; get version(): number; set version(_version: number); invalidateVersion(): void; forgetVersion(): Promise; get erased(): boolean; /** * Disable this cache in memory without touching persisted storage. */ discard(): void; /** * Erase values just for this datasource. After this call, {@link externalSet} is permanently disabled. */ erase(): Promise; /** * Re-add keys that were cleared during a successful {@link flush} but whose transaction subsequently failed to * commit. Without this, a commit failure would silently lose buffered writes. */ restoreDirtyKeys(keys: Set): void; /** * Flush dirty values to storage. When {@link tx} is provided, writes go through the shared transaction. * * Returns the set of keys that were flushed, so the caller can restore them via {@link restoreDirtyKeys} if * the enclosing transaction fails to commit. */ flush(tx?: StorageDriver.Transaction): Promise | undefined>; } export declare namespace DatasourceCache { /** * Standard key for storing the version. * * This conveys the version to the {@link Datasource}. */ const VERSION_KEY = "__version__"; interface Options { writer: RemoteWriter; nodeId: string; endpointNumber: EndpointNumber; behaviorId: string; initialValues?: Val.Struct; localWriter?: LocalWriter; buffer?: ClientCacheBuffer; } } //# sourceMappingURL=DatasourceCache.d.ts.map