/// <summary> /// Can be used to signal a remove event to the <see cref="ICacheManager{TCacheValue}"/> in case the underlying cache supports this and the implementation /// can react on evictions and expiration of cache items. /// </summary> /// <param name="key">The cache key.</param> /// <param name="region">The cache region. Can be null.</param> /// <param name="reason">The reason.</param> /// <exception cref="ArgumentNullException">If <paramref name="key"/> is null.</exception> protected void TriggerCacheSpecificRemove(string key, string region, CacheItemRemovedReason reason) { NotNullOrWhiteSpace(key, nameof(key)); if (Logger.IsEnabled(LogLevel.Debug)) { Logger.LogDebug("'{0}' triggered remove '{1}:{2}' because '{3}'.", Configuration.Name, region, key, reason); } OnCacheSpecificRemove?.Invoke(this, new CacheItemRemovedEventArgs(key, region, reason)); }
/// <summary> /// Can be used to signal a remove event to the <see cref="ICacheManager{TCacheValue}"/> in case the underlying cache supports this and the implementation /// can react on evictions and expiration of cache items. /// </summary> /// <param name="key">The cache key.</param> /// <param name="region">The cache region. Can be null.</param> /// <param name="reason">The reason.</param> /// <param name="value">The original cache value. The value might be null if the underlying cache system doesn't support returning the value on eviction.</param> /// <exception cref="ArgumentNullException">If <paramref name="key"/> is null.</exception> protected void TriggerCacheSpecificRemove(string key, string region, CacheItemRemovedReason reason, object value) { NotNullOrWhiteSpace(key, nameof(key)); if (Logger.IsEnabled(LogLevel.Debug)) { Logger.LogDebug("'{0}' triggered remove '{1}:{2}' because '{3}'.", Configuration.Name, region, key, reason); } // internal remove event, we don't know the level at this point => emit 0 OnCacheSpecificRemove?.Invoke(this, new CacheItemRemovedEventArgs(key, region, reason, value, 0)); }
/// <summary> /// Can be used to signal a remove event to the <see cref="ICacheManager{TCacheValue}"/> in case the underlying cache supports this and the implementation /// can react on evictions and expiration of cache items. /// </summary> /// <param name="key">The cache key.</param> /// <param name="region">The cache region. Can be null.</param> /// <param name="reason">The reason.</param> /// <param name="value">The original cache value. The value might be null if the underlying cache system doesn't support returning the value on eviction.</param> /// <exception cref="ArgumentNullException">If <paramref name="key"/> is null.</exception> protected void TriggerCacheSpecificRemove(TKey key, CacheItemRemovedReason reason, object value) { NotNull(key, nameof(key)); if (Logger.IsEnabled(LogLevel.Debug)) { Logger.LogDebug($"'{ Configuration.Name}' triggered remove '{key}' because '{reason}'."); } // internal remove event, we don't know the level at this point => emit 0 OnCacheSpecificRemove?.Invoke(this, new CacheItemRemovedEventArgs <TKey>(key, reason, value, 0)); }