Compare Exchange: How to Get Compare Exchange Values



public GetCompareExchangeValuesOperation(string[] keys)

public GetCompareExchangeValuesOperation(string startWith, int? start = null, int? pageSize = null)
Parameters Type Description
keys string[] List of keys to get
startWith string A common prefix for those keys whose values should be returned
start int The number of items that should be skipped
pageSize int The maximum number of values that will be retrieved

Returned object:

public class CompareExchangeValue<T>
    public readonly string Key;
    public readonly T Value;
    public readonly long Index;
Return Value Description
Dictionary<string, CompareExchangeValue<T>> A Dictionary containing 'Key' to 'CompareExchangeValue' associations

Example I - Get Values for Specified Keys

Dictionary<string, CompareExchangeValue<string>> compareExchangeValues
    = store.Operations.Send(
        new GetCompareExchangeValuesOperation<string>(new[] { "Key-1", "Key-2" }));

Example II - Get Values for Keys with Common Prefix

// Get values for keys that have the common prefix 'users'
// Retrieve maximum 20 entries
Dictionary<string, CompareExchangeValue<User>> compareExchangeValues
    = store.Operations.Send(new GetCompareExchangeValuesOperation<User>("users", 0, 20));