File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
BitFaster.Caching.UnitTests/Lru Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -866,6 +866,25 @@ public void WhenItemsExistClearRemovesAllItems()
866
866
lru . HotCount . Should ( ) . Be ( 0 ) ;
867
867
lru . WarmCount . Should ( ) . Be ( 0 ) ;
868
868
lru . ColdCount . Should ( ) . Be ( 0 ) ;
869
+ }
870
+
871
+ [ Fact ]
872
+ public void WhenWarmThenClearedIsWarmIsReset ( )
873
+ {
874
+ for ( int i = 0 ; i < 20 ; i ++ )
875
+ {
876
+ lru . GetOrAdd ( i , k => k . ToString ( ) ) ;
877
+ }
878
+
879
+ lru . Clear ( ) ;
880
+ lru . Count . Should ( ) . Be ( 0 ) ;
881
+
882
+ for ( int i = 0 ; i < 20 ; i ++ )
883
+ {
884
+ lru . GetOrAdd ( i , k => k . ToString ( ) ) ;
885
+ }
886
+
887
+ lru . Count . Should ( ) . Be ( capacity . Hot + capacity . Warm + capacity . Cold ) ;
869
888
}
870
889
871
890
[ Fact ]
Original file line number Diff line number Diff line change @@ -430,6 +430,8 @@ public void Clear()
430
430
CycleWarmUnchecked ( ItemRemovedReason . Cleared ) ;
431
431
TryRemoveCold ( ItemRemovedReason . Cleared ) ;
432
432
}
433
+
434
+ Volatile . Write ( ref this . isWarm , false ) ;
433
435
}
434
436
435
437
/// <summary>
You can’t perform that action at this time.
0 commit comments