コード例 #1
0
        /// <summary>
        /// Caches the data based upon a key
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public Task SetAsync(string key, T item)
        {
            var expiration = UtcNow.Add(this.duration);

            cache.Set(key, item, expiration);
            return(Task.FromResult(0));
        }
コード例 #2
0
        private DateTime ToAbsolute(CacheExpires expires)
        {
            // this is less sophisticated than the web caching implementation, but
            // it only needs to satisfy expectations of unit tests. they should always
            // use utc for abs

            if (expires == null)
            {
                return(CacheExpires.NoAbsoluteExpiration);
            }

            if (expires.Sliding != CacheExpires.NoSlidingExpiration)
            {
                return(UtcNow.Add(expires.Sliding));
            }

            return(expires.Absolute);
        }
コード例 #3
0
 public void AddToUtcTime(TimeSpan timeSpan)
 {
     UtcNow = UtcNow.Add(timeSpan);
 }