/// <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); }
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); }
public MemcachedSharpClient(string endPoint, MemcachedOptions options = null) { EndPoint = endPoint; _client = new global::MemcachedSharp.MemcachedClient(endPoint, options); IsAlive = true; }
/// <summary> /// Initializes a new instance of the <see cref="MemcachedProvider"/> class. /// </summary> public MemcachedProvider(MemcachedOptions options) { _options = options; }