使用cassandra .net驱动程序,我们面临以下问题:当使用参数化INSERT插入大量行时,应用程序内存使用量不断增长:
class Program
{
static Cluster cluster = Cluster.Builder()
.AddContactPoints(ConfigurationManager.AppSettings["address"])
.Build();
static Session session = cluster
.Connect(ConfigurationManager.AppSettings["keyspace"]);
static int counter = 0;
static void Main(string[] args)
{
for (int i = 0; i < 50; i++)
{
new Thread(() =>
{
while (true)
{
new Person()
{
Name = Interlocked.Increment(ref counter).ToString(),
ID = Guid.NewGuid(),
Data = new byte[4096],
}.Save(session);
}
}).Start();
}
Console.ReadLine();
}
}
class Person
{
public Guid ID
{
get;
set;
}
public string Name
{ …Run Code Online (Sandbox Code Playgroud)