Search Results for

    Show / Hide Table of Contents

    Class LWWRegister<T>

    Implements a 'Last Writer Wins Register' CRDT, also called a 'LWW-Register'.

    It is described in the paper A comprehensive study of Convergent and Commutative Replicated Data Types.

    Merge takes the register with highest timestamp. Note that this relies on synchronized clocks. LWWRegister<T> should only be used when the choice of value is not important for concurrent updates occurring within the clock skew.

    Merge takes the register updated by the node with lowest address (UniqueAddress is ordered) if the timestamps are exactly the same.

    Instead of using timestamps based on DateTime.UtcNow time it is possible to use a timestamp value based on something else, for example an increasing version number from a database record that is used for optimistic concurrency control.

    For first-write-wins semantics you can use the ReverseClock instead of the [[LWWRegister#defaultClock]]

    This class is immutable, i.e. "modifying" methods return a new instance.

    Inheritance
    object
    LWWRegister<T>
    Implements
    IReplicatedData<LWWRegister<T>>
    IReplicatedData
    IReplicatedDataSerialization
    IEquatable<LWWRegister<T>>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Akka.DistributedData
    Assembly: Akka.DistributedData.dll
    Syntax
    [Serializable]
    public sealed class LWWRegister<T> : IReplicatedData<LWWRegister<T>>, IReplicatedData, IReplicatedDataSerialization, IEquatable<LWWRegister<T>>
    Type Parameters
    Name Description
    T

    TBD

    Constructors

    | Edit this page View Source

    LWWRegister(UniqueAddress, T)

    TBD

    Declaration
    public LWWRegister(UniqueAddress node, T initial)
    Parameters
    Type Name Description
    UniqueAddress node

    TBD

    T initial

    TBD

    | Edit this page View Source

    LWWRegister(UniqueAddress, T, Clock<T>)

    TBD

    Declaration
    public LWWRegister(UniqueAddress node, T initial, Clock<T> clock)
    Parameters
    Type Name Description
    UniqueAddress node

    TBD

    T initial

    TBD

    Clock<T> clock

    TBD

    | Edit this page View Source

    LWWRegister(UniqueAddress, T, long)

    TBD

    Declaration
    public LWWRegister(UniqueAddress node, T value, long timestamp)
    Parameters
    Type Name Description
    UniqueAddress node

    TBD

    T value

    TBD

    long timestamp

    TBD

    Fields

    | Edit this page View Source

    DefaultClock

    Default clock is using max between DateTime.UtcNow.Ticks and current timestamp + 1.

    Declaration
    public static readonly Clock<T> DefaultClock
    Field Value
    Type Description
    Clock<T>
    | Edit this page View Source

    ReverseClock

    Reverse clock can be used for first-write-wins semantics. It's counting backwards, using min between -DateTime.UtcNow.Ticks and current timestamp - 1.

    Declaration
    public static readonly Clock<T> ReverseClock
    Field Value
    Type Description
    Clock<T>

    Properties

    | Edit this page View Source

    RegisterType

    Declaration
    public Type RegisterType { get; }
    Property Value
    Type Description
    Type
    | Edit this page View Source

    Timestamp

    Returns a timestamp used to determine precedence in current register updates.

    Declaration
    public long Timestamp { get; }
    Property Value
    Type Description
    long
    | Edit this page View Source

    UpdatedBy

    Returns a unique address of the last cluster node, that updated current register value.

    Declaration
    public UniqueAddress UpdatedBy { get; }
    Property Value
    Type Description
    UniqueAddress
    | Edit this page View Source

    Value

    Returns value of the current register.

    Declaration
    public T Value { get; }
    Property Value
    Type Description
    T

    Methods

    | Edit this page View Source

    Equals(LWWRegister<T>)

    Declaration
    public bool Equals(LWWRegister<T> other)
    Parameters
    Type Name Description
    LWWRegister<T> other
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()
    | Edit this page View Source

    Merge(IReplicatedData)

    TBD

    Declaration
    public IReplicatedData Merge(IReplicatedData other)
    Parameters
    Type Name Description
    IReplicatedData other

    TBD

    Returns
    Type Description
    IReplicatedData

    TBD

    | Edit this page View Source

    Merge(LWWRegister<T>)

    TBD

    Declaration
    public LWWRegister<T> Merge(LWWRegister<T> other)
    Parameters
    Type Name Description
    LWWRegister<T> other

    TBD

    Returns
    Type Description
    LWWRegister<T>

    TBD

    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    | Edit this page View Source

    WithValue(UniqueAddress, T, Clock<T>)

    Change the value of the register.

    You can provide your clock implementation instead of using timestamps based on DateTime.UtcNow.Ticks time. The timestamp can for example be an increasing version number from a database record that is used for optimistic concurrency control.

    Declaration
    public LWWRegister<T> WithValue(UniqueAddress node, T value, Clock<T> clock = null)
    Parameters
    Type Name Description
    UniqueAddress node

    TBD

    T value

    TBD

    Clock<T> clock

    TBD

    Returns
    Type Description
    LWWRegister<T>

    TBD

    Implements

    IReplicatedData<T>
    IReplicatedData
    IReplicatedDataSerialization
    IEquatable<T>

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET