-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Peck
committed
Dec 3, 2023
1 parent
e361650
commit 9c5d849
Showing
2 changed files
with
18 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,13 +85,13 @@ private void DrainBuffers() | |
public int Count => core.Count; | ||
|
||
///<inheritdoc/> | ||
public Optional<ICacheMetrics> Metrics => core.Metrics; | ||
public Optional<ICacheMetrics> Metrics => new(this.core.metrics); | ||
|
||
///<inheritdoc/> | ||
public Optional<ICacheEvents<K, V>> Events => core.Events; | ||
public Optional<ICacheEvents<K, V>> Events => Optional<ICacheEvents<K, V>>.None(); | ||
|
||
///<inheritdoc/> | ||
public CachePolicy Policy => core.Policy; | ||
public CachePolicy Policy => new(new Optional<IBoundedPolicy>(this), Optional<ITimePolicy>.None()); | ||
|
||
///<inheritdoc/> | ||
public ICollection<K> Keys => core.Keys; | ||
|
@@ -127,12 +127,6 @@ public void Clear() | |
core.Clear(); | ||
} | ||
|
||
///<inheritdoc/> | ||
public IEnumerator<KeyValuePair<K, V>> GetEnumerator() | ||
{ | ||
return core.GetEnumerator(); | ||
} | ||
|
||
///<inheritdoc/> | ||
public V GetOrAdd(K key, Func<K, V> valueFactory) | ||
{ | ||
|
@@ -202,10 +196,17 @@ public bool TryUpdate(K key, V value) | |
return core.TryUpdate(key, value); | ||
} | ||
|
||
///<inheritdoc/> | ||
public IEnumerator<KeyValuePair<K, V>> GetEnumerator() | ||
{ | ||
return core.GetEnumerator(); | ||
} | ||
|
||
///<inheritdoc/> | ||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return ((ConcurrentLfuCore<K, V, AccessOrderNode<K, V>, AccessOrderPolicy<K, V>>)core).GetEnumerator(); | ||
return core.GetEnumerator(); | ||
//return ((ConcurrentLfuCore<K, V, AccessOrderNode<K, V>, AccessOrderPolicy<K, V>>)core).GetEnumerator(); | ||
} | ||
|
||
#if DEBUG | ||
|
@@ -276,7 +277,7 @@ public KeyValuePair<K, V>[] Items | |
/// Based on the Caffeine library by [email protected] (Ben Manes). | ||
/// https://github.com/ben-manes/caffeine | ||
|
||
internal struct ConcurrentLfuCore<K, V, N, P> : ICache<K, V>, IAsyncCache<K, V>, IBoundedPolicy | ||
internal struct ConcurrentLfuCore<K, V, N, P> : IBoundedPolicy | ||
where N : LfuNode<K, V> | ||
where P : struct, INodePolicy<K, V, N> | ||
{ | ||
|
@@ -289,7 +290,7 @@ internal struct ConcurrentLfuCore<K, V, N, P> : ICache<K, V>, IAsyncCache<K, V>, | |
internal readonly StripedMpscBuffer<N> readBuffer; | ||
internal readonly MpscBoundedBuffer<N> writeBuffer; | ||
|
||
private readonly CacheMetrics metrics = new(); | ||
internal readonly CacheMetrics metrics = new(); | ||
|
||
private readonly CmSketch<K> cmSketch; | ||
|
||
|
@@ -342,12 +343,6 @@ public ConcurrentLfuCore(int concurrencyLevel, int capacity, IScheduler schedule | |
|
||
public int Capacity => this.capacity.Capacity; | ||
|
||
public Optional<ICacheMetrics> Metrics => new(this.metrics); | ||
|
||
public Optional<ICacheEvents<K, V>> Events => Optional<ICacheEvents<K, V>>.None(); | ||
|
||
public CachePolicy Policy => new(new Optional<IBoundedPolicy>(this), Optional<ITimePolicy>.None()); | ||
|
||
public ICollection<K> Keys => this.dictionary.Keys; | ||
|
||
public IScheduler Scheduler => scheduler; | ||
|
@@ -662,11 +657,6 @@ private void ScheduleAfterWrite() | |
} | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return ((ConcurrentLfuCore<K, V, N, P>)this).GetEnumerator(); | ||
} | ||
|
||
private void TryScheduleDrain() | ||
{ | ||
if (this.drainStatus.VolatileRead() >= DrainStatus.ProcessingToIdle) | ||
|