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

Commit 9694e1e

Browse files
committed
Allow specifying RedisConfig.DefaultMaxPoolSize to control pool size for both Pooled Client Managers
1 parent fc21393 commit 9694e1e

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/ServiceStack.Redis/RedisClientManagerConfig.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
namespace ServiceStack.Redis
1414
{
15-
public class RedisClientManagerConfig
16-
{
17-
public RedisClientManagerConfig()
18-
{
19-
AutoStart = true; //Simplifies the most common use-case - registering in an IOC
20-
}
15+
public class RedisClientManagerConfig
16+
{
17+
public RedisClientManagerConfig()
18+
{
19+
AutoStart = true; //Simplifies the most common use-case - registering in an IOC
20+
}
2121

22-
public long? DefaultDb { get; set; }
23-
public int MaxReadPoolSize { get; set; }
24-
public int MaxWritePoolSize { get; set; }
25-
public bool AutoStart { get; set; }
26-
}
22+
public long? DefaultDb { get; set; }
23+
public int MaxReadPoolSize { get; set; }
24+
public int MaxWritePoolSize { get; set; }
25+
public bool AutoStart { get; set; }
26+
}
2727
}

src/ServiceStack.Redis/RedisConfig.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public class RedisConfig
4747
/// </summary>
4848
public static int DefaultRetryTimeout = 3 * 1000;
4949

50+
/// <summary>
51+
/// Default Max Pool Size for Pooled Redis Client Managers (default none)
52+
/// </summary>
53+
public static int? DefaultMaxPoolSize;
54+
5055
/// <summary>
5156
/// The BackOff multiplier failed Auto Retries starts from (default 10ms)
5257
/// </summary>
@@ -104,6 +109,7 @@ public static void Reset()
104109
DefaultReceiveTimeout = -1;
105110
DefaultRetryTimeout = 3 * 1000;
106111
DefaultIdleTimeOutSecs = 240;
112+
DefaultMaxPoolSize = null;
107113
BackOffMultiplier = 10;
108114
BufferLength = 1450;
109115
BufferPoolMaxSize = 500000;

src/ServiceStack.Redis/RedisManagerPool.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace ServiceStack.Redis
1212
{
1313
public class RedisPoolConfig
1414
{
15-
public const int DefaultMaxPoolSize = 40;
15+
public static int DefaultMaxPoolSize = 40;
1616

1717
public RedisPoolConfig()
1818
{
19-
MaxPoolSize = DefaultMaxPoolSize;
19+
MaxPoolSize = RedisConfig.DefaultMaxPoolSize ?? DefaultMaxPoolSize;
2020
}
2121

2222
public int MaxPoolSize { get; set; }
@@ -52,6 +52,7 @@ public partial class RedisManagerPool
5252

5353
public RedisManagerPool() : this(RedisConfig.DefaultHost) { }
5454
public RedisManagerPool(string host) : this(new[] { host }) { }
55+
public RedisManagerPool(string host, RedisPoolConfig config) : this(new[] { host }, config) { }
5556
public RedisManagerPool(IEnumerable<string> hosts) : this(hosts, null) { }
5657

5758
public RedisManagerPool(IEnumerable<string> hosts, RedisPoolConfig config)

0 commit comments

Comments
 (0)