コード例 #1
0
        /// <summary>
        /// Uses the memcached provider (read config from configuration file).
        /// </summary>
        /// <param name="options">Options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="name">The name of this provider instance.</param>
        /// <param name="sectionName">The section name in the configuration file.</param>
        public static EasyCachingOptions UseMemcached(
            this EasyCachingOptions options
            , IConfiguration configuration
            , string name        = EasyCachingConstValue.DefaultMemcachedName
            , string sectionName = EasyCachingConstValue.MemcachedSection
            )
        {
            var dbConfig = configuration.GetSection(sectionName);
            var mOptions = new MemcachedOptions();

            dbConfig.Bind(mOptions);

            void configure(MemcachedOptions x)
            {
                x.EnableLogging  = mOptions.EnableLogging;
                x.MaxRdSecond    = mOptions.MaxRdSecond;
                x.LockMs         = mOptions.LockMs;
                x.SleepMs        = mOptions.SleepMs;
                x.SerializerName = mOptions.SerializerName;
                x.DBConfig       = mOptions.DBConfig;
            }

            options.RegisterExtension(new MemcachedOptionsExtension(name, configure));
            return(options);
        }
コード例 #2
0
        public MemcachedSharpClientCluster(IEnumerable <string> endPoints, MemcachedOptions options = null)
        {
            _timer   = new Timer(state => AsyncContext.Run(() => AwakenDeadServers()), null, 10000, 10000);
            _clients = endPoints.Select(a => new MemcachedSharpClient(a, options)).ToList();

            _nodes = new ConsistentHash <MemcachedSharpClient>(_clients);
        }
コード例 #3
0
 public MemcachedSharpClient(string endPoint, MemcachedOptions options = null)
 {
     EndPoint = endPoint;
     _client  = new global::MemcachedSharp.MemcachedClient(endPoint, options);
     IsAlive  = true;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemcachedProvider"/> class.
 /// </summary>
 public MemcachedProvider(MemcachedOptions options)
 {
     _options = options;
 }