private static void ValidateConfig(IMemcachedClientConfiguration config)
        {
            Assert.IsNotNull(config);

            Assert.IsInstanceOf(typeof(TestKeyTransformer), config.CreateKeyTransformer());
            Assert.IsInstanceOf(typeof(TestLocator), config.CreateNodeLocator());
            Assert.IsInstanceOf(typeof(TestTranscoder), config.CreateTranscoder());
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MemcachedClient"/> using the specified configuration instance.
        /// </summary>
        /// <param name="configuration">The memcachedClient configuration.</param>
        public MemcachedClient(IMemcachedClientConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.keyTransformer     = configuration.CreateKeyTransformer() ?? new DefaultKeyTransformer();
            this.transcoder         = configuration.CreateTranscoder() ?? new DefaultTranscoder();
            this.performanceMonitor = configuration.CreatePerformanceMonitor();

            this.pool = configuration.CreatePool();
            this.pool.Start();
        }
Exemple #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="T:MemcachedClient"/> using the specified configuration instance.
		/// </summary>
		/// <param name="configuration">The client configuration.</param>
		public MemcachedClient(IMemcachedClientConfiguration configuration)
		{
			if (configuration == null)
				throw new ArgumentNullException("configuration");

			this.keyTransformer = configuration.CreateKeyTransformer() ?? new DefaultKeyTransformer();
			this.transcoder = configuration.CreateTranscoder() ?? new DefaultTranscoder();
			this.performanceMonitor = configuration.CreatePerformanceMonitor();

			this.pool = configuration.CreatePool();
			this.pool.NodeFailed += (n) => { var f = this.NodeFailed; if (f != null) f(n); };
			this.StartPool();

			StoreOperationResultFactory = new DefaultStoreOperationResultFactory();
			GetOperationResultFactory = new DefaultGetOperationResultFactory();
			MutateOperationResultFactory = new DefaultMutateOperationResultFactory();
			ConcatOperationResultFactory = new DefaultConcatOperationResultFactory();
			RemoveOperationResultFactory = new DefaultRemoveOperationResultFactory();
		}