protected override void OnUpdate(CacheChange change, string userKey, ICoreItem oldValue, ICoreItem newValue, CoreItemCacheParams userParam) { switch (change) { case CacheChange.CacheCleared: if (oldValue != null) { throw new ArgumentException("oldValue"); } if (newValue != null) { throw new ArgumentException("newValue"); } _updates.Add(new CacheChangeData(_cacheId, change, null, null)); break; case CacheChange.ItemCreated: if (oldValue != null) { throw new ArgumentException("oldValue"); } if (newValue == null) { throw new ArgumentException("newValue"); } _updates.Add(new CacheChangeData(_cacheId, change, null, newValue)); Interlocked.Increment(ref _itemsCreated); break; case CacheChange.ItemExpired: case CacheChange.ItemRemoved: if (oldValue == null) { throw new ArgumentException("oldValue"); } if (newValue != null) { throw new ArgumentException("newValue"); } _updates.Add(new CacheChangeData(_cacheId, change, oldValue, null)); Interlocked.Increment(ref _itemsDeleted); break; case CacheChange.ItemUpdated: if (oldValue == null) { throw new ArgumentException("oldValue"); } if (newValue == null) { throw new ArgumentException("newValue"); } if (newValue.Id != oldValue.Id) { _updates.Add(new CacheChangeData(_cacheId, change, oldValue, newValue)); Interlocked.Increment(ref _itemsUpdated); } break; } }