Skip to content

Instantly share code, notes, and snippets.

@glikoz
Created June 6, 2012 15:09
Show Gist options
  • Save glikoz/2882459 to your computer and use it in GitHub Desktop.
Save glikoz/2882459 to your computer and use it in GitHub Desktop.
Threaded insert
private void ThreadedInsert(object obj)
{
RedisClient redis = new RedisClient(TestConfig.SingleHost);
Article a = new Article() { Name = "I Love Writing Test" };
a.Id = redis.As<Article>().GetNextSequence();
redis.Watch("idx:article:" + a.Name);
using (var trans = redis.CreateTransaction())
{
trans.QueueCommand(r => r.SetEntry("idx:article:" + a.Name, "urn:article:" + a.Id));
trans.QueueCommand(r => r.Store<Article>(a));
trans.Commit();
}
}
[TestMethod]
public void Can_create_id_hole()
{
for (int i = 0; i < 100; i++)
{
Task.Factory.StartNew(ThreadedInsert, null);
}
Thread.Sleep(5000);
Debugger.Break(); // Please check DB
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment