protected void InitConfig()
        {
            var id   = Interlocked.Increment(ref InstanceCount);
            var name = ClusterName + "-" + id;

            new ClusterBuilder(name)
            .Endpoints("10.2.4.10:11211")
            .Register();

            var configBuilder = new ClientConfigurationBuilder();

            ConfigureServices(configBuilder.Cluster(name).Use);

            config = configBuilder.Create();
        }
        protected void InitConfig()
        {
            lock (InitLock)
            {
                if (clusterName == null)
                {
                    var p = Interlocked.Increment(ref Port);
                    server = MemcachedServer.Run(p);

                    clusterName = ClusterName + p;
                    new ClusterBuilder(clusterName).Endpoints("localhost:" + p).Register();

                    var clientBuilder = new ClientConfigurationBuilder();
                    ConfigureServices(clientBuilder.Cluster(clusterName).Use);

                    config = clientBuilder.Create();
                }
            }
        }
Ejemplo n.º 3
0
        protected void InitConfig()
        {
            lock (initLock)
            {
                if (config != null)
                {
                    return;
                }

                var ports = Enumerable.Range(1, 3).Select(i => Interlocked.Increment(ref Port)).ToArray();

                clusterName = ClusterPrefix + Interlocked.Increment(ref InstanceCounter);
                servers     = ports.Select(p => MemcachedServer.Run(p, verbose: true)).ToArray();

                new ClusterBuilder(clusterName)
                .Endpoints(ports.Select(p => "localhost:" + p).ToArray())
                .Register();

                var configBuilder = new ClientConfigurationBuilder();
                ConfigureServices(configBuilder.Cluster(clusterName).Use);

                config = configBuilder.Create();
            }
        }