diff --git a/BitFaster.Caching.ThroughputAnalysis/CacheFactory.cs b/BitFaster.Caching.ThroughputAnalysis/CacheFactory.cs index faede8d5..b4212c87 100644 --- a/BitFaster.Caching.ThroughputAnalysis/CacheFactory.cs +++ b/BitFaster.Caching.ThroughputAnalysis/CacheFactory.cs @@ -1,4 +1,5 @@  +using System; using System.Collections.Generic; using System.Data; using BitFaster.Caching.Lfu; @@ -105,6 +106,35 @@ public ConcurrentLfuFactory(int capacity) } } + public class ConcurrentTLfuFactory : ICacheFactory + { + private readonly int capacity; + + public ConcurrentTLfuFactory(int capacity) + { + this.capacity = capacity; + } + + public string Name => "ConcurrentTLfu"; + + public DataRow DataRow { get; set; } + + public (IScheduler, ICache) Create(int threadCount) + { + var scheduler = new BackgroundThreadScheduler(); + + var cache = new ConcurrentLfuBuilder() + .WithCapacity(capacity) + .WithScheduler(scheduler) + .WithConcurrencyLevel(threadCount) + .WithKeyComparer(EqualityComparer.Default) + .WithExpireAfterWrite(TimeSpan.FromHours(1)) + .Build(); + + return (scheduler, cache); + } + } + public class ClassicLruFactory : ICacheFactory { private readonly int capacity;