示例#1
0
        public CouchbaseClient(string bucketName, params Server[] servers)
        {
            lock (_gate)
            {
                _reconnectMemcachedAsync = AsyncPattern.Create<TcpClient, ReconnectAttempt>(
                    BeginMemcachedReconnection,
                    OnMemcacachedReconnectionCompleted,
                    OnMemcachedReconnectionError);

                _bucketName = bucketName;
                var cluster = new Cluster();

                foreach (var server in servers)
                {
                    cluster.AddServer(server);
                }
                
                BeginStreamingFromNewServersInCluster(cluster);
                
                _cluster = cluster;
            }
        }
示例#2
0
        public static Server EnsureServer(Cluster cluster, string hostname, int memcachedPort)
        {
            var id = Server.GetId(hostname, memcachedPort);
            var server = cluster.GetServerById(id);
            if (server == null)
            {
                server = new Server(hostname, memcachedPort);
                cluster.AddServer(server);
            }

            return server;
        }