@@ -85,13 +85,13 @@ private void DrainBuffers()
8585 public int Count => core . Count ;
8686
8787 ///<inheritdoc/>
88- public Optional < ICacheMetrics > Metrics => core . Metrics ;
88+ public Optional < ICacheMetrics > Metrics => new ( this . core . metrics ) ;
8989
9090 ///<inheritdoc/>
91- public Optional < ICacheEvents < K , V > > Events => core . Events ;
91+ public Optional < ICacheEvents < K , V > > Events => Optional < ICacheEvents < K , V > > . None ( ) ;
9292
9393 ///<inheritdoc/>
94- public CachePolicy Policy => core . Policy ;
94+ public CachePolicy Policy => new ( new Optional < IBoundedPolicy > ( this ) , Optional < ITimePolicy > . None ( ) ) ;
9595
9696 ///<inheritdoc/>
9797 public ICollection < K > Keys => core . Keys ;
@@ -127,12 +127,6 @@ public void Clear()
127127 core . Clear ( ) ;
128128 }
129129
130- ///<inheritdoc/>
131- public IEnumerator < KeyValuePair < K , V > > GetEnumerator ( )
132- {
133- return core . GetEnumerator ( ) ;
134- }
135-
136130 ///<inheritdoc/>
137131 public V GetOrAdd ( K key , Func < K , V > valueFactory )
138132 {
@@ -202,10 +196,17 @@ public bool TryUpdate(K key, V value)
202196 return core . TryUpdate ( key , value ) ;
203197 }
204198
199+ ///<inheritdoc/>
200+ public IEnumerator < KeyValuePair < K , V > > GetEnumerator ( )
201+ {
202+ return core . GetEnumerator ( ) ;
203+ }
204+
205205 ///<inheritdoc/>
206206 IEnumerator IEnumerable . GetEnumerator ( )
207207 {
208- return ( ( ConcurrentLfuCore < K , V , AccessOrderNode < K , V > , AccessOrderPolicy < K , V > > ) core ) . GetEnumerator ( ) ;
208+ return core . GetEnumerator ( ) ;
209+ //return ((ConcurrentLfuCore<K, V, AccessOrderNode<K, V>, AccessOrderPolicy<K, V>>)core).GetEnumerator();
209210 }
210211
211212#if DEBUG
@@ -276,7 +277,7 @@ public KeyValuePair<K, V>[] Items
276277 /// Based on the Caffeine library by ben.manes@gmail.com (Ben Manes).
277278 /// https://github.com/ben-manes/caffeine
278279
279- internal struct ConcurrentLfuCore < K , V , N , P > : ICache < K , V > , IAsyncCache < K , V > , IBoundedPolicy
280+ internal struct ConcurrentLfuCore < K , V , N , P > : IBoundedPolicy
280281 where N : LfuNode < K , V >
281282 where P : struct , INodePolicy < K , V , N >
282283 {
@@ -289,7 +290,7 @@ internal struct ConcurrentLfuCore<K, V, N, P> : ICache<K, V>, IAsyncCache<K, V>,
289290 internal readonly StripedMpscBuffer < N > readBuffer ;
290291 internal readonly MpscBoundedBuffer < N > writeBuffer ;
291292
292- private readonly CacheMetrics metrics = new ( ) ;
293+ internal readonly CacheMetrics metrics = new ( ) ;
293294
294295 private readonly CmSketch < K > cmSketch ;
295296
@@ -342,12 +343,6 @@ public ConcurrentLfuCore(int concurrencyLevel, int capacity, IScheduler schedule
342343
343344 public int Capacity => this . capacity . Capacity ;
344345
345- public Optional < ICacheMetrics > Metrics => new ( this . metrics ) ;
346-
347- public Optional < ICacheEvents < K , V > > Events => Optional < ICacheEvents < K , V > > . None ( ) ;
348-
349- public CachePolicy Policy => new ( new Optional < IBoundedPolicy > ( this ) , Optional < ITimePolicy > . None ( ) ) ;
350-
351346 public ICollection < K > Keys => this . dictionary . Keys ;
352347
353348 public IScheduler Scheduler => scheduler ;
@@ -662,11 +657,6 @@ private void ScheduleAfterWrite()
662657 }
663658 }
664659
665- IEnumerator IEnumerable . GetEnumerator ( )
666- {
667- return ( ( ConcurrentLfuCore < K , V , N , P > ) this ) . GetEnumerator ( ) ;
668- }
669-
670660 private void TryScheduleDrain ( )
671661 {
672662 if ( this . drainStatus . VolatileRead ( ) >= DrainStatus . ProcessingToIdle )
0 commit comments