using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
namespace Microsoft.Extensions.Caching.Memory
private IList<IDisposable> _expirationTokenRegistrations;
private IList<PostEvictionCallbackRegistration> _postEvictionCallbacks;
private bool _isExpired;
+ private readonly ILogger _logger;
internal IList<IChangeToken> _expirationTokens;
internal DateTimeOffset? _absoluteExpiration;
internal CacheEntry(
object key,
Action<CacheEntry> notifyCacheEntryDisposed,
- Action<CacheEntry> notifyCacheOfExpiration)
+ Action<CacheEntry> notifyCacheOfExpiration,
+ ILogger logger)
{
if (key == null)
{
throw new ArgumentNullException(nameof(notifyCacheOfExpiration));
}
+ if (logger == null)
+ {
+ throw new ArgumentNullException(nameof(logger));
+ }
+
Key = key;
_notifyCacheEntryDisposed = notifyCacheEntryDisposed;
_notifyCacheOfExpiration = notifyCacheOfExpiration;
_scope = CacheEntryHelper.EnterScope(this);
+ _logger = logger;
}
/// <summary>
{
registration.EvictionCallback?.Invoke(entry.Key, entry.Value, entry.EvictionReason, registration.State);
}
- catch (Exception)
+ catch (Exception e)
{
// This will be invoked on a background thread, don't let it throw.
- // TODO: LOG
+ entry._logger.LogError(e, "EvictionCallback invoked failed");
}
}
}