示例#1
0
        public PrivateServerFixture()
        {
            var p = Interlocked.Increment(ref port);

            server = MemcachedServer.Run(p);

            cfg = ClusterName + p;
            new ClusterBuilder(cfg).Endpoints("localhost:" + p).Register();
            ClientConfig = new ClientConfigurationBuilder().Cluster(cfg).Create();
        }
示例#2
0
        private static IContainer GetConfig()
        {
            lock (InitLock)
            {
                if (Config == null)
                {
                    server = MemcachedServer.Run(Port);

                    new ClusterBuilder(ClusterName).Endpoints("localhost:" + Port).Register();
                    Config = new ClientConfigurationBuilder().Cluster(ClusterName).Create();
                }

                refCount++;
            }

            return(Config);
        }
        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();
                }
            }
        }
示例#4
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();
            }
        }