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

Commit 9150370

Browse files
committed
share same redisCollection instance for all threads
1 parent 260a259 commit 9150370

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/Console.Tests/HashCollectionStressTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ namespace TestRedisConnection
1111
public class HashCollectionStressTests
1212
{
1313
private IRedisClientsManager clientsManager;
14+
private RedisCachedCollection<string, string> redisCollection;
15+
1416
private int running = 0;
1517
private long writeCount = 0;
1618
private long readCount = 0;
1719

1820
public void Execute(string ipAddress, int noOfThreads = 64)
1921
{
2022
clientsManager = new PooledRedisClientManager(ipAddress);
23+
24+
redisCollection = new RedisCachedCollection<string, string>(
25+
clientsManager, "Threads: " + 64);
2126

2227
var StartedAt = DateTime.UtcNow;
2328
Interlocked.Increment(ref running);
@@ -45,9 +50,6 @@ public void Execute(string ipAddress, int noOfThreads = 64)
4550

4651
public void WorkerLoop()
4752
{
48-
var redisCollection = new RedisCachedCollection<string, string>(
49-
clientsManager, "Thread: " + Thread.CurrentThread.ManagedThreadId);
50-
5153
while (Interlocked.CompareExchange(ref running, 0, 0) > 0)
5254
{
5355
redisCollection.ContainsKey("key");

0 commit comments

Comments
 (0)