public Task Save(CacheEntry entry) { var policy = new CacheItemPolicy(); // TODO: Allow this to be configured // Why 8 minutes? Because it feels right. policy.AbsoluteExpiration = DateTimeOffset.Now + TimeSpan.FromMinutes(8); policy.RemovedCallback = OnCacheEntryRemoved; _cache.Set(entry.Key, entry.Value, policy); return _completedTask; }
public Task Save(CacheEntry entry) { string rawEntry = JsonConvert.SerializeObject(entry); return Task.Factory.StartNew(() => File.AppendAllText(_path, rawEntry + Environment.NewLine)); }