Example #1
0
        /// <summary>
        /// 取得Cassandra的Cluster实现
        /// </summary>
        /// <param name="connectionSetting">数据库设置</param>
        /// <returns>Cluster实现</returns>
        public static Cluster CreateCluster(CassandraConnectionSetting connectionSetting)
        {
            var builder = Cluster.Builder()
                          .AddContactPoints(connectionSetting.EndPoints);

            if (connectionSetting.WithCredentials)
            {
                builder.WithCredentials(connectionSetting.User, connectionSetting.Password);
            }
            var cluster = builder.Build();

            return(cluster);
        }
Example #2
0
        /// <summary>
        /// 取得Cassandra的Cluster实现
        /// </summary>
        /// <param name="connectString">数据库连接字符串</param>
        /// <returns>Cluster实现</returns>
        public static Cluster CreateCluster(string connectString)
        {
            var connectSetting = new CassandraConnectionSetting(connectString);

            return(CreateCluster(connectSetting));
        }