public void Add(TKey key, TValue value) { lock (_internalCache) { _internalCache[key] = new CacheValue <TValue>(value, DateTime.Now + Expiration); } }
public bool Equals(CacheValue <TValue> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.Value, Value)); }
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; } } }