Skip to content

Commit f4344e1

Browse files
authored
lfu no lock count (#424)
* fix lfu count * comment * fix release ---------
1 parent 77a7325 commit f4344e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

BitFaster.Caching/Lfu/ConcurrentLfu.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Diagnostics;
66
using System.Diagnostics.CodeAnalysis;
7+
using System.Linq;
78
using System.Runtime.InteropServices;
89
using System.Threading;
910
using System.Threading.Tasks;
@@ -13,7 +14,6 @@
1314
using BitFaster.Caching.Scheduler;
1415

1516
#if DEBUG
16-
using System.Linq;
1717
using System.Text;
1818
#endif
1919

@@ -113,8 +113,9 @@ public ConcurrentLfu(int concurrencyLevel, int capacity, IScheduler scheduler, I
113113
this.drainBuffer = new LfuNode<K, V>[this.readBuffer.Capacity];
114114
}
115115

116+
// No lock count: https://arbel.net/2013/02/03/best-practices-for-using-concurrentdictionary/
116117
///<inheritdoc/>
117-
public int Count => this.dictionary.Count;
118+
public int Count => this.dictionary.Skip(0).Count();
118119

119120
///<inheritdoc/>
120121
public int Capacity => this.capacity.Capacity;

0 commit comments

Comments
 (0)