public virtual void Set <T>(string key, T value, TimeSpan expiration) { try { if (IsDisabled || (value == null && !CacheNullItems)) { return; } var expirationDate = expiration == TimeSpan.MaxValue ? DateTime.MaxValue : DateTime.Now.Add(expiration); var item = new CacheItem <T> { Key = key, Value = value, Expiration = expiration, ExpirationTime = expirationDate, }; _cache.Set <T>(item); } catch (Exception e) { throw new CacheServiceException(string.Format("Error setting key {0} in cache {1}", key, CacheId), e); } }