Example #1
0
        /// <summary>
        /// Returns cache options for absolute expiration.
        /// </summary>
        /// <remarks>
        /// A cached value might expire sooner than the specified time.
        /// </remarks>
        /// <param name="absoluteExpirationTime">The absolute time when the cached value
        /// will expire</param>
        /// <returns></returns>
        public static CacheOptions AbsoluteExpiration(DateTime absoluteExpirationTime)
        {
            CacheOptions options = new CacheOptions();

            options.absoluteExpirationTime = absoluteExpirationTime;
            return(options);
        }
Example #2
0
        /// <summary>
        /// Returns cache options for sliding expiration.
        /// </summary>
        /// <remarks>
        /// A cached value might expire sooner than the specified time.
        /// </remarks>
        /// <param name="slidingExpirationTimeSpan">The time when a cached value will
        /// expire relative to the time it was added to the cache</param>
        /// <returns>The cache options</returns>
        public static CacheOptions SlidingExpiration(TimeSpan slidingExpirationTimeSpan)
        {
            CacheOptions options = new CacheOptions();

            options.slidingExpirationTimeSpan = slidingExpirationTimeSpan;
            return(options);
        }
Example #3
0
        /// <inheritdoc />
        protected override void InternalSet(string key, object value, CacheOptions options)
        {
            DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow();

            lock (items)
            {
                items[key] = new CacheItem(value, expirationTime);

                if (expirationTime < nextExpirationTime)
                {
                    nextExpirationTime = expirationTime;
                }
            }
        }
Example #4
0
        /// <inheritdoc />
        public void Set(string key, object value, CacheOptions options)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (key.Length == 0)
            {
                throw new ArgumentException("Key must not be empty.", "key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            InternalSet(key, value, options);
        }
Example #5
0
 /// <summary>
 /// Returns cache options for absolute expiration.
 /// </summary>
 /// <remarks>
 /// A cached value might expire sooner than the specified time.
 /// </remarks>
 /// <param name="absoluteExpirationTime">The absolute time when the cached value
 /// will expire</param>
 /// <returns></returns>
 public static CacheOptions AbsoluteExpiration(DateTime absoluteExpirationTime)
 {
     CacheOptions options = new CacheOptions();
     options.absoluteExpirationTime = absoluteExpirationTime;
     return options;
 }
Example #6
0
 /// <summary>
 /// Returns cache options for sliding expiration.
 /// </summary>
 /// <remarks>
 /// A cached value might expire sooner than the specified time.
 /// </remarks>
 /// <param name="slidingExpirationTimeSpan">The time when a cached value will
 /// expire relative to the time it was added to the cache</param>
 /// <returns>The cache options</returns>
 public static CacheOptions SlidingExpiration(TimeSpan slidingExpirationTimeSpan)
 {
     CacheOptions options = new CacheOptions();
     options.slidingExpirationTimeSpan = slidingExpirationTimeSpan;
     return options;
 }
Example #7
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
     innerCache.Set(partitionPrefix + key, value, options);
 }
Example #8
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
 }
Example #9
0
 /// <summary>
 /// Internal implementation of <see cref="Set(string, object, CacheOptions)" />.
 /// All parameters have been validated by the base class.
 /// </summary>
 /// <param name="key">The cache key</param>
 /// <param name="value">The value to set, must not be null</param>
 /// <param name="options">The cache options for the value</param>
 protected abstract void InternalSet(string key, object value, CacheOptions options);
Example #10
0
        /// <inheritdoc />
        protected override void InternalSet(string key, object value, CacheOptions options)
        {
            DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow();

            lock (items)
            {
                items[key] = new CacheItem(value, expirationTime);

                if (expirationTime < nextExpirationTime)
                    nextExpirationTime = expirationTime;
            }
        }
Example #11
0
 /// <summary>
 /// Internal implementation of <see cref="Set(string, object, CacheOptions)" />.
 /// All parameters have been validated by the base class.
 /// </summary>
 /// <param name="key">The cache key</param>
 /// <param name="value">The value to set, must not be null</param>
 /// <param name="options">The cache options for the value</param>
 protected abstract void InternalSet(string key, object value, CacheOptions options);
Example #12
0
        /// <inheritdoc />
        public void Set(string key, object value, CacheOptions options)
        {
            if (key == null)
                throw new ArgumentNullException("key");
            if (key.Length == 0)
                throw new ArgumentException("Key must not be empty.", "key");
            if (value == null)
                throw new ArgumentNullException("value");

            InternalSet(key, value, options);
        }
Example #13
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
 }
Example #14
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
     innerCache.Set(partitionPrefix + key, value, options);
 }