Skip to content

Commit f158338

Browse files
Pull public methods/properties to IMemoryCache
1 parent 6e68aa4 commit f158338

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

HttpClient.Caching/InMemory/IMemoryCache.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Microsoft.Extensions.Caching.InMemory
88
/// </summary>
99
public interface IMemoryCache : IDisposable
1010
{
11+
int Count { get; }
12+
1113
/// <summary>Gets the item associated with this key if present.</summary>
1214
/// <param name="key">An object identifying the requested entry.</param>
1315
/// <param name="value">The located value or null.</param>
@@ -23,6 +25,8 @@ public interface IMemoryCache : IDisposable
2325
/// <param name="key">An object identifying the entry.</param>
2426
void Remove(object key);
2527

28+
void Compact(double percentage);
29+
2630
void Clear();
2731
}
2832
}

HttpClient.Caching/InMemory/MemoryCache.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ namespace Microsoft.Extensions.Caching.InMemory
1212
public class MemoryCache : IMemoryCache
1313
{
1414
private readonly ConcurrentDictionary<object, CacheEntry> entries;
15-
private bool disposed;
1615
private readonly Action<CacheEntry> setEntry;
1716
private readonly Action<CacheEntry> entryExpirationNotification;
1817
private readonly ISystemClock clock;
1918
private readonly TimeSpan expirationScanFrequency;
19+
2020
private DateTimeOffset lastExpirationScan;
21+
private bool disposed;
2122

2223
public int Count => this.entries.Count;
2324

@@ -110,10 +111,7 @@ private void SetEntry(CacheEntry entry)
110111
entry.InvokeEvictionCallbacks();
111112
}
112113

113-
if (cacheEntry != null)
114-
{
115-
cacheEntry.InvokeEvictionCallbacks();
116-
}
114+
cacheEntry?.InvokeEvictionCallbacks();
117115
}
118116
else
119117
{

0 commit comments

Comments
 (0)