Beispiel #1
0
        /// <summary>
        /// Inserts a cache entry into the cache, overwriting any existing cache entry.
        /// </summary>
        /// <param name="key">A unique identifier for the cache entry.</param>
        /// <param name="value">The object to insert.</param>
        /// <param name="absoluteExpiration">The fixed date and time at which the cache entry will expire.</param>
        /// <param name="regionName">Ignored.</param>
        /// <returns>true if insertion succeeded, false otherwise.</returns>
        public override bool Add(string key, object value, DateTimeOffset absoluteExpiration, string regionName = null)
        {
            // Sanitize
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("cannot be null, empty, or white space", "key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var cacheKey = string.Format(_cacheKey, key);

            _cacheClient.AddOrUpdate(cacheKey, value, absoluteExpiration: absoluteExpiration);

            return(true);
        }