see on GitHub

Compare Exchange : How to Get Compare Exchange Value



public GetCompareExchangeValueOperation(string key)

Returned object:

public class CompareExchangeValue<T>
    public readonly string Key;
    public readonly T Value;
    public readonly long Index;

Key string The unique object identifier
Value T The existing value that Key has
Index long The version number of the Value that is stored for the specified Key

Example I - Value is 'long'

CompareExchangeValue<long> readResult =
    store.Operations.Send(new GetCompareExchangeValueOperation<long>("NextClientId"));

long value = readResult.Value;

Example II - Value is a custom object

CompareExchangeValue<User> readResult =
    store.Operations.Send(new GetCompareExchangeValueOperation<User>("AdminUser"));

User admin = readResult.Value;