Example #1
0
 public void Add(TKey key, TValue value)
 {
     lock (_internalCache)
     {
         _internalCache[key] = new CacheValue <TValue>(value, DateTime.Now + Expiration);
     }
 }
Example #2
0
 public bool Equals(CacheValue <TValue> other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Value, Value));
 }
Example #3
0
 public TValue this[TKey key]
 {
     get
     {
         var cacheValue = _internalCache[key];
         return(cacheValue != null && cacheValue.ExpiresOn > DateTime.Now ? cacheValue.Value : null);
     }
     set
     {
         var cacheValue = new CacheValue <TValue>(value, DateTime.Now + Expiration);
         lock (_internalCache)
         {
             _internalCache[key] = cacheValue;
         }
     }
 }