public void RefreshShouldSetExpireDate() { var value = new CacheValue <string>("value", new TimeSpan(1, 0, 0)); value.Refresh(new TimeSpan(1, 0, 0)); Assert.Equal(DateTime.UtcNow.AddHours(1), value.ExpiredDateUtc, new TimeSpan(0, 0, 1)); }
public void ForMaxValueTimespanRefreshShouldSetMaxExpireDate() { var value = new CacheValue <string>("value", new TimeSpan(0, 0, 0)); value.Refresh(TimeSpan.MaxValue); Assert.Equal(DateTime.MaxValue, value.ExpiredDateUtc); }
public GoogleStorageBenchmarkRepository( IApplicationLifetime lifetime, ILoggerFactory loggerFactory, GoogleCredential credential) { StorageClient client = StorageClient.Create(credential); cache = new TimerCache <CacheValue>(lifetime, CacheRefreshTime, () => CacheValue.Refresh(cache?.Value ?? CacheValue.Empty, client), loggerFactory, CacheValue.Empty); }
public BenchmarkRepository( IApplicationLifetime lifetime, ILoggerFactory loggerFactory, IStorageRepository storage, int limit) { var logger = loggerFactory.CreateLogger <BenchmarkRepository>(); cache = new TimerCache <CacheValue>( cacheName: "benchmarks", lifetime, CacheRefreshTime, () => CacheValue.Refresh(cache?.Value ?? CacheValue.Empty, storage, logger, limit), loggerFactory, CacheValue.Empty); cache.Start(); }