Skip to main content
Version: v2

IConsensusRegisterCollection Interface

A distributed data structure that holds a set of registers with update versions. On concurrent updates, a register internally stores all possible versions of a value by using reference sequence number of the incoming update.

Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies we support:

Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single copy of the data, and that every operation appears to take effect atomically at one point in time. This definition implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set operation, where we compare a register sequence number with the incoming reference sequence number. The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on the value. So we can safely return the first value.

LWW: The last write to a key always wins.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/register-collection/legacy.

For more information about our API support guarantees, see here.

Signature​

export interface IConsensusRegisterCollection<T = any> extends ISharedObject<IConsensusRegisterCollectionEvents>

Extends: ISharedObject<IConsensusRegisterCollectionEvents>

Type Parameters​

ParameterDefaultDescription
Tany

Methods​

MethodAlertsReturn TypeDescription
keys()Betastring[]Returns the keys.
read(key, policy)BetaT | undefinedRetrieves the agreed upon value for the register based on policy. Returns undefined if not present.
readVersions(key)BetaT[] | undefinedRetrives all concurrent versions. Undefined if not present.
write(key, value)BetaPromise<boolean>Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion. For a non existent register, it will attempt to create a new register with the specified value.

Method Details​

keys​

Returns the keys.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

keys(): string[];

Returns​

Return type: string[]

read​

Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

read(key: string, policy?: ReadPolicy): T | undefined;

Parameters​

ParameterModifiersTypeDescription
keystring
policyoptionalReadPolicy

Returns​

Return type: T | undefined

readVersions​

Retrives all concurrent versions. Undefined if not present.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

readVersions(key: string): T[] | undefined;

Parameters​

ParameterTypeDescription
keystring

Returns​

Return type: T[] | undefined

write​

Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion. For a non existent register, it will attempt to create a new register with the specified value.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

write(key: string, value: T): Promise<boolean>;

Parameters​

ParameterTypeDescription
keystring
valueT

Returns​

Promise if write was non-concurrent

Return type: Promise<boolean>