@@ -49,8 +49,8 @@ public void Clear(string prefix = "")
4949 public int GetCount ( string prefix = "" )
5050 {
5151 return string . IsNullOrWhiteSpace ( prefix )
52- ? _memory . Count
53- : _memory . Count ( x => x . Key . StartsWith ( prefix , StringComparison . OrdinalIgnoreCase ) ) ;
52+ ? _memory . Values . Where ( x => x . ExpiresAt > SystemClock . UtcNow ) . Count ( )
53+ : _memory . Values . Where ( x => x . Key . StartsWith ( prefix , StringComparison . OrdinalIgnoreCase ) && x . ExpiresAt > SystemClock . UtcNow ) . Count ( ) ;
5454 }
5555
5656 internal void RemoveExpiredKey ( string key )
@@ -283,7 +283,7 @@ public int RemoveByPattern(string searchKey, SearchKeyPattern searchPattern)
283283 public IEnumerable < string > GetAllKeys ( string prefix )
284284 {
285285 return _memory . Values . Where ( x => x . Key . StartsWith ( prefix , StringComparison . OrdinalIgnoreCase ) && x . ExpiresAt > SystemClock . UtcNow )
286- . Select ( x=> x . Key ) . ToList ( ) ;
286+ . Select ( x => x . Key ) . ToList ( ) ;
287287 }
288288
289289 private static bool FilterByPattern ( string key , string searchKey , SearchKeyPattern searchKeyPattern )
@@ -314,10 +314,10 @@ public IDictionary<string, CacheValue<T>> GetAll<T>(IEnumerable<string> keys)
314314
315315 public IDictionary < string , CacheValue < T > > GetAll < T > ( string prefix = "" )
316316 {
317- var values = string . IsNullOrEmpty ( prefix )
318- ? _memory . Values . Where ( x => x . ExpiresAt > SystemClock . UtcNow )
317+ var values = string . IsNullOrEmpty ( prefix )
318+ ? _memory . Values . Where ( x => x . ExpiresAt > SystemClock . UtcNow )
319319 : _memory . Values . Where ( x => x . Key . StartsWith ( prefix , StringComparison . OrdinalIgnoreCase ) && x . ExpiresAt > SystemClock . UtcNow ) ;
320-
320+
321321 return values . ToDictionary ( k => k . Key , v => new CacheValue < T > ( v . GetValue < T > ( _options . EnableReadDeepClone ) , true ) ) ;
322322 }
323323
0 commit comments