Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 260a259

Browse files
committed
Try again with the instance outside the loop and clean up RetryAction
1 parent c03f10f commit 260a259

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

tests/Console.Tests/HashCollectionStressTests.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public void Execute(string ipAddress, int noOfThreads = 64)
4545

4646
public void WorkerLoop()
4747
{
48+
var redisCollection = new RedisCachedCollection<string, string>(
49+
clientsManager, "Thread: " + Thread.CurrentThread.ManagedThreadId);
50+
4851
while (Interlocked.CompareExchange(ref running, 0, 0) > 0)
4952
{
50-
var redisCollection = new RedisCachedCollection<string, string>(
51-
clientsManager, "Thread: " + Thread.CurrentThread.ManagedThreadId);
52-
5353
redisCollection.ContainsKey("key");
5454
Interlocked.Increment(ref readCount);
5555

@@ -241,29 +241,19 @@ public Func<TValue, TKey> GetUniqueIdAction
241241

242242
private void RetryAction(Action<IRedisClient> action)
243243
{
244-
int i = 0;
245-
while (true)
244+
try
246245
{
247-
try
246+
using (var redis = RedisConnection)
248247
{
249-
using (var redis = RedisConnection)
250-
{
251-
action(redis);
252-
return;
253-
}
254-
}
255-
catch (Exception ex)
256-
{
257-
Console.WriteLine(ex);
258-
throw;
259-
260-
//if (i++ < 3)
261-
//{
262-
// continue;
263-
//}
264-
//throw;
248+
action(redis);
249+
return;
265250
}
266251
}
252+
catch (Exception ex)
253+
{
254+
Console.WriteLine(ex);
255+
throw;
256+
}
267257
}
268258

269259
private TOut RetryAction<TOut>(Func<IRedisClient, TOut> action)

0 commit comments

Comments
 (0)