Skip to content

Commit

Permalink
fix: no check expires when get cache count in memory cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Memoyu committed Oct 12, 2023
1 parent 2fd7fdc commit c87b059
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/EasyCaching.InMemory/Internal/InMemoryCaching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void Clear(string prefix = "")
public int GetCount(string prefix = "")
{
return string.IsNullOrWhiteSpace(prefix)
? _memory.Count
: _memory.Count(x => x.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
? _memory.Values.Where(x => x.ExpiresAt > SystemClock.UtcNow).Count()
: _memory.Values.Where(x => x.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && x.ExpiresAt > SystemClock.UtcNow).Count();
}

internal void RemoveExpiredKey(string key)
Expand Down

0 comments on commit c87b059

Please sign in to comment.