NCache 4.6 - Online Documentation

Sample Usage of Aggregator

 
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.
 
      To utilize Aggregator, include the following namespace in your application: Alachisoft.NCache.Runtime.Aggregation.
 
        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
            }
   
     
See Also