Beispiel #1
0
        public T Get(string key)
        {
            if (_items.TryGetValue(key, out SimpleCacheItem <T> value) && value.Expires > DateTime.Now)
            {
                if (value.Expiration.Type == ExpirationType.Sliding)
                {
                    _items[key] = new SimpleCacheItem <T>(value.Item, value.Expiration);
                }

                return(value.Item);
            }

            return(default(T));
        }
Beispiel #2
0
 public void Set(string key, T value, CacheExpiration expiration)
 {
     _items[key] = new SimpleCacheItem <T>(value, expiration);
 }