Ejemplo n.º 1
0
        /// <summary>
        /// Adds a <see cref="BucketCacheHandle{TCacheValue}"/> with the required name.
        /// <para>
        /// This handle requires a Couchbase <see cref="ClientConfiguration"/> to be defined with
        /// the <paramref name="couchbaseConfigurationKey"/> matching the configuration's key.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="couchbaseConfigurationKey">
        /// The Couchbase configuration identifier will be used as name for the cache handle and to
        /// retrieve the connection configuration.
        /// </param>
        /// <param name="bucketName">
        /// The name of the Couchbase bucket which should be used by the cache handle.
        /// </param>
        /// <param name="isBackplaneSource">
        /// Set this to true if this cache handle should be the source of the backplane.
        /// <para>This setting will be ignored if no backplane is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="System.ArgumentNullException">If bucketName is null.</exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithCouchbaseCacheHandle(this ConfigurationBuilderCachePart part, string couchbaseConfigurationKey, string bucketName, bool isBackplaneSource)
        {
            NotNull(part, nameof(part));
            NotNullOrWhiteSpace(bucketName, nameof(bucketName));

            return(part.WithHandle(typeof(BucketCacheHandle <>), couchbaseConfigurationKey + ":" + bucketName, isBackplaneSource));
        }
        /// <summary>
        /// Adds a <see cref="MemcachedCacheHandle{TCacheValue}"/> using the <paramref name="clientConfiguration"/> to setup a <see cref="MemcachedClient"/> instance.
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="clientConfiguration">The <see cref="MemcachedClientConfiguration"/> to use to create the <see cref="MemcachedClient"/> for this cache handle.</param>
        /// <param name="isBackplaneSource">
        /// Set this to true if this cache handle should be the source of the backplane.
        /// <para>This setting will be ignored if no backplane is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown if <paramref name="clientConfiguration"/> is null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithMemcachedCacheHandle(this ConfigurationBuilderCachePart part, MemcachedClientConfiguration clientConfiguration, bool isBackplaneSource = true)
        {
            NotNull(part, nameof(part));
            NotNull(clientConfiguration, nameof(clientConfiguration));

            return(part.WithHandle(typeof(MemcachedCacheHandle <>), Guid.NewGuid().ToString(), isBackplaneSource, clientConfiguration));
        }
        /// <summary>
        /// Add a <see cref="RedisCacheHandle"/> with the required name.
        /// <para>
        /// This handle requires a redis configuration to be defined with the
        /// <paramref name="redisConfigurationId"/> matching the configuration's id.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="redisConfigurationId">
        /// The redis configuration identifier will be used as name for the cache handle and to
        /// retrieve the connection configuration.
        /// </param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithRedisCacheHandle(this ConfigurationBuilderCachePart part, string redisConfigurationId, bool isBackPlateSource)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            return(part.WithHandle(typeof(RedisCacheHandle <>), redisConfigurationId, isBackPlateSource));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a <see cref="MemcachedCacheHandle"/> with the required name.
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="handleName">The name to be used for the cache handle.</param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithMemcachedCacheHandle(this ConfigurationBuilderCachePart part, string handleName, bool isBackPlateSource)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            return(part.WithHandle(typeof(MemcachedCacheHandle <>), handleName, isBackPlateSource));
        }
        /// <summary>
        /// Adds a <see cref="BucketCacheHandle{TCacheValue}"/> with the required name.
        /// <para>
        /// This handle requires a Couchbase <see cref="ClientConfiguration"/> to be defined with
        /// the <paramref name="couchbaseConfigurationKey"/> matching the configuration's key.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="couchbaseConfigurationKey">
        /// The Couchbase configuration identifier will be used as name for the cache handle and to
        /// retrieve the connection configuration.
        /// </param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithCouchbaseCacheHandle(
            this ConfigurationBuilderCachePart part,
            string couchbaseConfigurationKey,
            bool isBackPlateSource)
        {
            NotNull(part, nameof(part));

            return(part.WithHandle(typeof(BucketCacheHandle <>), couchbaseConfigurationKey, isBackPlateSource));
        }
        /// <summary>
        /// Add a <see cref="BucketCacheHandle"/> with the required name.
        /// <para>
        /// This handle requires a Couchbase <see cref="ClientConfiguration"/> to be defined with
        /// the <paramref name="couchbaseConfigurationKey"/> matching the configuration's key.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="couchbaseConfigurationKey">
        /// The Couchbase configuration identifier will be used as name for the cache handle and to
        /// retrieve the connection configuration.
        /// </param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithCouchbaseCacheHandle(this ConfigurationBuilderCachePart part, string couchbaseConfigurationKey, bool isBackPlateSource)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            return(part.WithHandle(typeof(BucketCacheHandle <>), couchbaseConfigurationKey, isBackPlateSource));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds a <see cref="BucketCacheHandle{TCacheValue}" /> using the configuration referenced via <paramref name="couchbaseConfigurationKey" />.
        /// <para>
        /// The cache handle needs configuration specific to Couchbase, see remarks for details.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="couchbaseConfigurationKey">The configuration identifier.</param>
        /// <param name="bucketName">The name of the Couchbase bucket which should be used by the cache handle.</param>
        /// <param name="isBackplaneSource">Set this to <c>true</c> if this cache handle should be the source of the backplane. This setting will be ignored if no backplane is configured.</param>
        /// <returns>
        /// The part.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="bucketName" /> or <paramref name="couchbaseConfigurationKey" /> is null.</exception>
        /// <remarks>
        /// The Couchbase cache handle requires configuration which can be defined via:
        /// <list type="bullet"><item>
        /// <term>
        /// A configuration with a matching <paramref name="couchbaseConfigurationKey" /> being added via <see cref="WithCouchbaseConfiguration(ConfigurationBuilderCachePart, string, ClientConfiguration)" />.
        /// </term></item>
        /// <item><term>
        /// A cluster with a matching <paramref name="couchbaseConfigurationKey" /> being added via <see cref="WithCouchbaseCluster(ConfigurationBuilderCachePart, string, ICluster)" />.
        /// </term></item>
        /// <item><term>
        /// A <c>CouchbaseClientSection</c> configured in <c>App/Web.config</c> (only available on full .NET Framework).
        /// </term></item>
        /// <item><term>
        /// Or, the cluster has been configured via <see cref="ClusterHelper" /> and CacheManager will use the cluster returned by <see cref="ClusterHelper.Get" />.
        /// Anyways, this will be the last fallback which, if nothing has been configured at all, will fall back to the default server endpoint on <c>127.0.0.1:8091</c>.
        /// </term></item>
        /// </list>
        /// <para>
        /// If your cluster requires authentication, use either the <see cref="ClusterHelper" /> or add a <see cref="ICluster" /> with valid authentication via <c>cluster.Authenticate(...)</c>.
        /// </para>
        /// </remarks>
        public static ConfigurationBuilderCacheHandlePart WithCouchbaseCacheHandle(
            this ConfigurationBuilderCachePart part,
            string couchbaseConfigurationKey,
            string bucketName      = CouchbaseConfigurationManager.DefaultBucketName,
            bool isBackplaneSource = true)
        {
            NotNull(part, nameof(part));
            NotNullOrWhiteSpace(bucketName, nameof(bucketName));

            return(part.WithHandle(typeof(BucketCacheHandle <>), couchbaseConfigurationKey, isBackplaneSource, new BucketCacheHandleAdditionalConfiguration()
            {
                BucketName = bucketName
            }));
        }
        /// <summary>
        /// Add a <see cref="BucketCacheHandle"/> with the required name.
        /// <para>
        /// This handle requires a Couchbase <see cref="ClientConfiguration"/> to be defined with
        /// the <paramref name="couchbaseConfigurationKey"/> matching the configuration's key.
        /// </para>
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="couchbaseConfigurationKey">
        /// The Couchbase configuration identifier will be used as name for the cache handle and to
        /// retrieve the connection configuration.
        /// </param>
        /// <param name="bucketName">
        /// The name of the Couchbase bucket which should be used by the cache handle.
        /// </param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="System.ArgumentNullException">If bucketName is null.</exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithCouchbaseCacheHandle(this ConfigurationBuilderCachePart part, string couchbaseConfigurationKey, string bucketName, bool isBackPlateSource)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            if (string.IsNullOrWhiteSpace(bucketName))
            {
                throw new ArgumentNullException("bucketName");
            }

            return(part.WithHandle(typeof(BucketCacheHandle <>), couchbaseConfigurationKey + ":" + bucketName, isBackPlateSource));
        }
        /// <summary>
        /// Adds a <see cref="MemcachedCacheHandle{TCacheValue}"/>. The <paramref name="configurationName"/> must match with cache configured via enyim configuration section.
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="configurationName">The configuration name.</param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or handleType are null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithMemcachedCacheHandle(this ConfigurationBuilderCachePart part, string configurationName, bool isBackPlateSource)
        {
            NotNull(part, nameof(part));

            return(part.WithHandle(typeof(MemcachedCacheHandle <>), configurationName, isBackPlateSource));
        }
        /// <summary>
        /// Adds a <see cref="MemcachedCacheHandle{TCacheValue}"/>. The <paramref name="configurationName"/> must match with cache configured via enyim configuration section.
        /// </summary>
        /// <param name="part">The builder part.</param>
        /// <param name="configurationName">The configuration name.</param>
        /// <param name="client">The <see cref="MemcachedClient"/> to use for this cache handle.</param>
        /// <param name="isBackplaneSource">
        /// Set this to true if this cache handle should be the source of the backplane.
        /// <para>This setting will be ignored if no backplane is configured.</para>
        /// </param>
        /// <returns>The part.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown if <paramref name="client"/> is null.
        /// </exception>
        public static ConfigurationBuilderCacheHandlePart WithMemcachedCacheHandle(this ConfigurationBuilderCachePart part, string configurationName, MemcachedClient client, bool isBackplaneSource = true)
        {
            NotNull(part, nameof(part));

            return(part.WithHandle(typeof(MemcachedCacheHandle <>), configurationName, isBackplaneSource, client));
        }
        /// <summary>
        /// Adds a <see cref="RedisCacheHandle{TCacheValue}"/>.
        /// This handle requires a redis configuration to be defined with the given <paramref name="redisConfigurationKey"/>.
        /// </summary>
        /// <param name="part">The builder instance.</param>
        /// <param name="redisConfigurationKey">
        /// The redis configuration key will be used to find a matching redis connection configuration.
        /// </param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// This setting will be ignored if no back plate is configured.
        /// </param>
        /// <returns>The builder instance.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="redisConfigurationKey"/> is null.</exception>
        public static ConfigurationBuilderCacheHandlePart WithRedisCacheHandle(this ConfigurationBuilderCachePart part, string redisConfigurationKey, bool isBackPlateSource)
        {
            NotNull(part, nameof(part));

            return(part.WithHandle(typeof(RedisCacheHandle <>), redisConfigurationKey, isBackPlateSource));
        }
 /// <summary>
 /// Adds a <see cref="MemoryCacheHandle{TCacheValue}" /> using a <see cref="System.Runtime.Caching.MemoryCache"/> instance with the given <paramref name="instanceName"/>.
 /// The named cache instance can be configured via <c>app/web.config</c> <c>system.runtime.caching</c> section.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <param name="instanceName">The name to be used for the cache instance.</param>
 /// <param name="isBackPlateSource">Set this to true if this cache handle should be the source of the back plate.
 /// This setting will be ignored if no back plate is configured.</param>
 /// <returns>
 /// The builder part.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">If part is null.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="instanceName"/> is null.</exception>
 public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part, string instanceName, bool isBackPlateSource)
 => part?.WithHandle(typeof(MemoryCacheHandle <>), instanceName, isBackPlateSource);
 /// <summary>
 /// Adds a <see cref="MemoryCacheHandle{TCacheValue}" /> using a <see cref="System.Runtime.Caching.MemoryCache"/>.
 /// The name of the cache instance will be 'default'.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <returns>The builder part.</returns>
 public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part)
 => part?.WithHandle(typeof(MemoryCacheHandle <>), DefaultName, false);
 public static ConfigurationBuilderCacheHandlePart WithAppFabricCacheHandle(this ConfigurationBuilderCachePart part, string handleName, bool isBackPlateSource)
 {
     return(part.WithHandle(typeof(AppFabricCacheHandle <>), handleName, isBackPlateSource));
 }
 /// <summary>
 /// Adds a <see cref="MemoryCacheHandle{TCacheValue}" /> using a <see cref="System.Runtime.Caching.MemoryCache"/>.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <returns>The builder part.</returns>
 public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part)
 => part?.WithHandle(typeof(MemoryCacheHandle <>), Guid.NewGuid().ToString("N"), false);
 /// <summary>
 /// Adds a <see cref="SystemWebCacheHandle{TCacheValue}" /> to the cache manager.
 /// This handle uses <c>System.Web.Caching.Cache</c> and requires <c>HttpContext.Current</c> to be not null.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <param name="instanceName">The name to be used for the cache handle instance.</param>
 /// <param name="isBackplaneSource">Set this to true if this cache handle should be the source of the backplane.
 /// This setting will be ignored if no backplane is configured.</param>
 /// <returns>
 /// The builder part.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">If part is null.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="instanceName"/> is null.</exception>
 public static ConfigurationBuilderCacheHandlePart WithSystemWebCacheHandle(this ConfigurationBuilderCachePart part, string instanceName, bool isBackplaneSource)
 => part?.WithHandle(typeof(SystemWebCacheHandle <>), instanceName, isBackplaneSource);
Ejemplo n.º 17
0
 /// <summary>
 /// Adds a <see cref="MemoryCacheHandle{TCacheValue}" /> using a <see cref="Microsoft.Extensions.Caching.Memory"/> instance with the given <paramref name="instanceName"/>.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <param name="instanceName">The name to be used for the cache instance.</param>
 /// <param name="isBackplaneSource">Set this to true if this cache handle should be the source of the backplane.
 /// This setting will be ignored if no backplane is configured.</param>
 /// <returns>
 /// The builder part.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">If part is null.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="instanceName"/> is null.</exception>
 public static ConfigurationBuilderCacheHandlePart WithMicrosoftMemoryCacheHandle(
     this ConfigurationBuilderCachePart part, string instanceName, bool isBackplaneSource)
 => part?.WithHandle(typeof(MemoryCacheHandle <>), instanceName, isBackplaneSource);
 public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part, string handleName, bool isBackPlateSource)
 {
     return(part.WithHandle(typeof(MemoryCacheHandle <>), handleName, isBackPlateSource));
 }
 public static ConfigurationBuilderCacheHandlePart WithFileCacheHandle(this ConfigurationBuilderCachePart part, SerializationBinder binder, bool calculateCacheSize = false, TimeSpan cleanInterval = new TimeSpan())
 => part?.WithHandle(typeof(FileCacheHandle <>), DefaultCacheName, false, new FileCacheHandleAdditionalConfiguration {
     SerializationBinder = binder, CalculateCacheSize = calculateCacheSize, CleanInterval = cleanInterval
 });
 /// <summary>
 /// Adds a <see cref="FileCacheHandle{TCacheValue}" /> using a <see cref="System.Runtime.Caching.FileCache"/> instance with the given <paramref name="instanceName"/>.
 /// The named cache instance can be configured via <c>app/web.config</c> <c>system.runtime.caching</c> section.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <param name="cacheRoot">The name to be used for the cache instance.</param>
 /// <param name="calculateCacheSize">A flag indicating whether or not to calculate the cache size on initialization</param>
 /// <param name="cleanInterval">If supplied, sets the interval of time that must occur between self cleans</param>
 /// <returns>
 /// The builder part.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="part"/> is null.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="cacheRoot"/> is null.</exception>
 public static ConfigurationBuilderCacheHandlePart WithFileCacheHandle(this ConfigurationBuilderCachePart part, string cacheRoot, bool calculateCacheSize = false, TimeSpan cleanInterval = new TimeSpan())
 => part?.WithHandle(typeof(FileCacheHandle <>), cacheRoot, false, new FileCacheHandleAdditionalConfiguration {
     CalculateCacheSize = calculateCacheSize, CleanInterval = cleanInterval
 });
 /// <summary>
 /// Adds a <see cref="MemoryCacheHandle{TCacheValue}" /> using a <see cref="System.Runtime.Caching.MemoryCache"/>.
 /// The name of the cache instance will be 'default'.
 /// </summary>
 /// <param name="part">The builder part.</param>
 /// <param name="isBackplaneSource">Set this to true if this cache handle should be the source of the backplane.
 /// This setting will be ignored if no backplane is configured.</param>
 /// <returns>
 /// The builder part.
 /// </returns>
 /// <returns>The builder part.</returns>
 public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part, bool isBackplaneSource = false)
 => part?.WithHandle(typeof(MemoryCacheHandle <>), DefaultName, isBackplaneSource);