Ejemplo n.º 1
0
        /// <summary>
        /// Adds the specified toCache to this cache under the key specified for the duration specified and assigns the tag specified to it.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="toCache">The resultset to cache</param>
        /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
        /// <param name="overwriteIfPresent">if set to <c>true</c> it will replace an existing cached set with the one specified.</param>
        /// <param name="tag">The tag under which the resultset has to be cached.</param>
        public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration, bool overwriteIfPresent, string tag)
        {
            var keyToUse    = _keyStore.GetPersistentCacheKey(key, duration, tag);
            var policyToUse = ProduceCacheItemPolicy(duration);

            if (overwriteIfPresent)
            {
                _memoryCache.Set(keyToUse, toCache, policyToUse);
            }
            else
            {
                _memoryCache.Add(keyToUse, toCache, policyToUse);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the specified toCache to this cache under the key specified for the duration specified
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="toCache">The resultset to cache</param>
 /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
 /// <remarks>
 /// If an object is already present under 'key', Add is a no-op.
 /// </remarks>
 public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration)
 {
     Add(key, toCache, duration, false, string.Empty);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the specified toCache to this cache under the key specified for the duration specified
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="toCache">The resultset to cache</param>
 /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
 /// <param name="overwriteIfPresent">if set to <c>true</c> it will replace an existing cached set with the one specified.</param>
 public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration, bool overwriteIfPresent)
 {
     Add(key, toCache, duration, overwriteIfPresent, string.Empty);
 }
 /// <summary>
 /// Adds the specified toCache to this cache under the key specified for the duration specified and assigns the tag specified to it.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="toCache">The resultset to cache</param>
 /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
 /// <param name="overwriteIfPresent">if set to <c>true</c> it will replace an existing cached set with the one specified.</param>
 /// <param name="tag">The tag under which the resultset has to be cached.</param>
 public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration, bool overwriteIfPresent, string tag)
 {
     var keyToUse = _keyStore.GetPersistentCacheKey(key, duration, tag);
     var policyToUse = ProduceCacheItemPolicy(duration);
     if(overwriteIfPresent)
     {
         _memoryCache.Set(keyToUse, toCache, policyToUse);
     }
     else
     {
         _memoryCache.Add(keyToUse, toCache, policyToUse);
     }
 }
 /// <summary>
 /// Adds the specified toCache to this cache under the key specified for the duration specified
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="toCache">The resultset to cache</param>
 /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
 /// <param name="overwriteIfPresent">if set to <c>true</c> it will replace an existing cached set with the one specified.</param>
 public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration, bool overwriteIfPresent)
 {
     Add(key, toCache, duration, overwriteIfPresent, string.Empty);
 }
 /// <summary>
 /// Adds the specified toCache to this cache under the key specified for the duration specified
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="toCache">The resultset to cache</param>
 /// <param name="duration">The duration how long the resultset will stay in the cache.</param>
 /// <remarks>
 /// If an object is already present under 'key', Add is a no-op.
 /// </remarks>
 public void Add(CacheKey key, CachedResultset toCache, TimeSpan duration)
 {
     Add(key, toCache, duration, false, string.Empty);
 }