Sample Usage of Aggregator
To utilize Aggregator, include the following namespace in your application:
Alachisoft.NCache.Runtime.Aggregation
.
After implementing the custom interfaces or if using the built-in Aggregator of
NCache, you can invoke the Aggregate
API to execute the Aggregator task.
Aggregate()
returns the resulting value of Aggregator operation.
try
{
int value;
//Using the built-in aggregator.
value = (int)cache.Aggregate(new BasicTypeExtractor(),
BuiltInAggregator.IntegerSum());
//Getting a single value by custom implemented aggregator
value = (int)cache.Aggregate(new BasicTypeExtractor(), new
IntAggregator("MIN"));
//Getting a single value by custom implemented aggregator
value = (int)cache.Aggregate(new BasicTypeExtractor(), new
IntAggregator("MAX"));
}
catch (Exception exp)
{
//handle exception
}