Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 7
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
     innerCache.Set(partitionPrefix + key, value, options);
 }
Ejemplo n.º 8
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
 }
Ejemplo n.º 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);
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
 }
Ejemplo n.º 14
0
 /// <inheritdoc />
 protected override void InternalSet(string key, object value, CacheOptions options)
 {
     innerCache.Set(partitionPrefix + key, value, options);
 }