Skip to main content

Compare Exchange: How to Get Compare Exchange Values

Syntax

Methods:

public GetCompareExchangeValuesOperation(string startWith, int? start = null, int? pageSize = null)
ParametersTypeDescription
startWithstringA common prefix for those keys whose values should be returned
startintThe number of items that should be skipped
pageSizeintThe 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 ValueDescription
Dictionary<string, CompareExchangeValue<T>>A Dictionary containing 'Key' to 'CompareExchangeValue' associations

You can also get compare exchange values through the session cluster transactions at session.Advanced.ClusterTransaction.

This method also exposes methods getting compare exchange lazily.

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));