public JasmineTimeoutCache(int capacity, Action <Tkey, Tvalue> itemRemovedCallback) { Capacity = capacity; _itemRemovedCallback = itemRemovedCallback; _scheduler = new JasmineTimeoutScheduler(new TimeoutJobManager(capacity)); _scheduler.Start(); }
/// <summary> /// /// </summary> /// <param name="threshold"> over it in time interval will be pushed into cache </param> /// <param name="capacity"></param> /// <param name="loader">laod value by key <see cref="ILoader{Tkey, TValue}"/></param> /// <param name="checkInterval"><see cref="LruTimeoutJob"/> will clear precache every interval</param> public JasmineLruCache(byte threshold, int capacity, ILoader <Tkey, Tvalue> loader, int checkInterval) { Capacity = capacity; _threshold = threshold; _loader = loader ?? throw new ArgumentNullException(nameof(loader)); _scheduler = new JasmineTimeoutScheduler(new TimeoutJobManager(2), 1); _scheduler.Start(); var job = new LruTimeoutJob(_precache, checkInterval); _scheduler.Schedule(job); }
static void Main(string[] args) { var sc = new JasmineTimeoutScheduler(new TimeoutJobManager(100000)); sc.Schedule(new EchoJob(DateTime.Now.AddMilliseconds(10000))); sc.Schedule(new EchoJob(DateTime.Now.AddMilliseconds(10000))); sc.Schedule(new EchoJob(DateTime.Now.AddMilliseconds(20000))); sc.Schedule(new EchoJob(DateTime.Now.AddMilliseconds(30000))); sc.Schedule(new EchoJob(DateTime.Now.AddMilliseconds(40000))); sc.Start(); Console.Read(); }
public LruFileCache(byte threshold, long maxMemoryUsage, int checkInterval, IFileLoader loader) { MaxMemoryUsage = maxMemoryUsage; _threshold = threshold; _loader = loader ?? throw new ArgumentNullException(nameof(loader)); _scheduler = new JasmineTimeoutScheduler(new TimeoutJobManager(2), 1); _scheduler.Start(); var job = new LruTimeoutJob(_precache, checkInterval); _scheduler.Schedule(job); }