diff --git a/src/UiPath.Caching/MemoryCacheSetter.cs b/src/UiPath.Caching/MemoryCacheSetter.cs index 90d649b..6e8b359 100644 --- a/src/UiPath.Caching/MemoryCacheSetter.cs +++ b/src/UiPath.Caching/MemoryCacheSetter.cs @@ -16,14 +16,13 @@ internal abstract class MemoryCacheSetter( ) { private readonly KeyMasker _masker = masker ?? KeyMasker.Off; + private readonly ICacheEntrySizeProvider _sizeProvider = memoryCacheOptions.SizeProvider ?? new DefaultCacheEntrySizeProvider(); private const string EventRefreshMetadataFailed = "Caching." + nameof(MemoryCacheSetter) + "." + nameof(RefreshMetadata) + ".Failed"; private const string PropCacheKey = "CacheKey"; private const string PropTopicKey = "TopicKey"; private const string PropTransportId = "TransportId"; - private ICacheEntrySizeProvider SizeProvider { get; } = memoryCacheOptions.SizeProvider ?? new DefaultCacheEntrySizeProvider(); - protected TimeProvider Clock { get; } = clock; public bool Set(ICacheEntryOptions options, ICacheEntry item, Type entryType, TimeSpan? maxExpiration) @@ -43,7 +42,7 @@ public bool Set(ICacheEntryOptions options, ICacheEntry item, Type entryType, Ti memOptions.RegisterPostEvictionCallback(PostEviction, token); if(memoryCacheOptions.SizeLimit.HasValue) { - memOptions.SetSize(SizeProvider.GetSize(item)); + memOptions.SetSize(_sizeProvider.GetSize(item)); } memoryCache.Set(options.CacheKey, item, memOptions); return true;