示例#1
0
        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;
        }
示例#2
0
 public Task Save(CacheEntry entry)
 {
     string rawEntry = JsonConvert.SerializeObject(entry);
     return Task.Factory.StartNew(() => File.AppendAllText(_path, rawEntry + Environment.NewLine));
 }