Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EasyCaching.Memcached.DefaultMemcachedCachingProvider"/> class.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="memcachedClients">Memcached client.</param>
        /// <param name="options">Options.</param>
        /// <param name="loggerFactory">Logger factory.</param>
        public DefaultMemcachedCachingProvider(
            string name,
            IEnumerable <EasyCachingMemcachedClient> memcachedClients,
            MemcachedOptions options,
            ILoggerFactory loggerFactory = null)
        {
            this._name            = name;
            this._memcachedClient = memcachedClients.Single(x => x.Name.Equals(this._name));
            this._options         = options;

            if (options.EnableLogging)
            {
                this.Logger = loggerFactory.CreateLogger <DefaultMemcachedCachingProvider>();
            }

            this._cacheStats = new CacheStats();

            this.ProviderName        = this._name;
            this.ProviderType        = CachingProviderType.Memcached;
            this.ProviderStats       = this._cacheStats;
            this.ProviderMaxRdSecond = _options.MaxRdSecond;

            _info = new ProviderInfo
            {
                CacheStats     = _cacheStats,
                EnableLogging  = options.EnableLogging,
                LockMs         = options.LockMs,
                MaxRdSecond    = options.MaxRdSecond,
                ProviderName   = ProviderName,
                ProviderType   = ProviderType,
                SerializerName = options.SerializerName,
                SleepMs        = options.SleepMs,
                CacheNulls     = options.CacheNulls,
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EasyCaching.Memcached.DefaultMemcachedCachingProvider"/> class.
        /// </summary>
        /// <param name="memcachedClients">Memcached client.</param>
        /// <param name="options">Options.</param>
        /// <param name="loggerFactory">Logger factory.</param>
        public DefaultMemcachedCachingProvider(
            IEnumerable <EasyCachingMemcachedClient> memcachedClients,
            IOptionsMonitor <MemcachedOptions> options,
            ILoggerFactory loggerFactory = null)
        {
            this._name            = EasyCachingConstValue.DefaultMemcachedName;
            this._memcachedClient = memcachedClients.FirstOrDefault(x => x.Name.Equals(this._name));
            this._options         = options.CurrentValue;
            this._logger          = loggerFactory?.CreateLogger <DefaultMemcachedCachingProvider>();

            this._cacheStats = new CacheStats();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EasyCaching.Memcached.DefaultMemcachedCachingProvider"/> class.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="memcachedClients">Memcached client.</param>
        /// <param name="options">Options.</param>
        /// <param name="loggerFactory">Logger factory.</param>
        public DefaultMemcachedCachingProvider(
            string name,
            IEnumerable <EasyCachingMemcachedClient> memcachedClients,
            MemcachedOptions options,
            ILoggerFactory loggerFactory = null)
        {
            this._name            = name;
            this._memcachedClient = memcachedClients.FirstOrDefault(x => x.Name.Equals(this._name));
            this._options         = options;
            this._logger          = loggerFactory?.CreateLogger <DefaultMemcachedCachingProvider>();

            this._cacheStats = new CacheStats();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EasyCaching.Memcached.DefaultMemcachedCachingProvider"/> class.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="memcachedClients">Memcached client.</param>
        /// <param name="options">Options.</param>
        /// <param name="loggerFactory">Logger factory.</param>
        public DefaultMemcachedCachingProvider(
            string name,
            IEnumerable <EasyCachingMemcachedClient> memcachedClients,
            MemcachedOptions options,
            ILoggerFactory loggerFactory = null)
        {
            this._name            = name;
            this._memcachedClient = memcachedClients.Single(x => x.Name.Equals(this._name));
            this._options         = options;
            this._logger          = loggerFactory?.CreateLogger <DefaultMemcachedCachingProvider>();
            this._cacheStats      = new CacheStats();

            this.ProviderName          = this._name;
            this.ProviderType          = CachingProviderType.Memcached;
            this.ProviderStats         = this._cacheStats;
            this.ProviderMaxRdSecond   = _options.MaxRdSecond;
            this.IsDistributedProvider = true;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EasyCaching.Memcached.DefaultMemcachedCachingProvider"/> class.
        /// </summary>
        /// <param name="memcachedClients">Memcached client.</param>
        /// <param name="options">Options.</param>
        /// <param name="loggerFactory">Logger factory.</param>
        public DefaultMemcachedCachingProvider(
            IEnumerable <EasyCachingMemcachedClient> memcachedClients,
            IOptionsMonitor <MemcachedOptions> options,
            ILoggerFactory loggerFactory = null)
        {
            this._name            = EasyCachingConstValue.DefaultMemcachedName;
            this._memcachedClient = memcachedClients.FirstOrDefault(x => x.Name.Equals(this._name));
            this._options         = options.CurrentValue;
            this._logger          = loggerFactory?.CreateLogger <DefaultMemcachedCachingProvider>();

            this._cacheStats = new CacheStats();

            this.ProviderName          = this._name;
            this.ProviderStats         = this._cacheStats;
            this.ProviderType          = _options.CachingProviderType;
            this.ProviderOrder         = _options.Order;
            this.ProviderMaxRdSecond   = _options.MaxRdSecond;
            this.IsDistributedProvider = true;
        }