Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/UiPath.Caching/MemoryCacheSetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down