private bool Populate(VirtualCache cache, bool slidingExpiration, int start) { var target = cache; _logger.Information("{0}: Start of Populating target cache {1}.", DateTime.Now, target.Name); try { // using a batch allows more efficient use of SOP data store so it can do bulk insert. CacheKeyValue[] batch = new CacheKeyValue[5000]; var policy = new CacheItemPolicy() { SlidingExpiration = new TimeSpan(0, 15, 0) }; for (int i = start; i < start + MaxCacheEntries; i++) { batch[i % batch.Length] = new CacheKeyValue() { Key = string.Format("Hello{0}", i), Value = string.Format("Value{0}", i), Policy = policy }; if (i % batch.Length == batch.Length - 1) { target.SetValues(batch); } } } catch (Exception exc) { _logger.Fatal(exc, "{0}: Failed Populating target cache {1}.", DateTime.Now, target.Name); return(false); } _logger.Information("{0}: End Populating target cache {1}.", DateTime.Now, target.Name); return(true); }