Created
June 6, 2012 15:09
-
-
Save glikoz/2882459 to your computer and use it in GitHub Desktop.
Threaded insert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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