Skip to content

Commit 9f2b398

Browse files
authored
Merge pull request #43 from cnblogs/hotfix-issue-42
Fix incorrect checking of MinPoolSize and MaxPoolSize
2 parents 552c6b5 + 85f2569 commit 9f2b398

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

Enyim.Caching/Configuration/MemcachedClientConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public MemcachedClientConfiguration(
5252
SocketPool = new SocketPoolConfiguration();
5353
if (options.SocketPool != null)
5454
{
55+
options.SocketPool.CheckPoolSize();
5556
options.SocketPool.CheckTimeout();
5657

5758
SocketPool.MinPoolSize = options.SocketPool.MinPoolSize;

Enyim.Caching/Configuration/MemcachedClientOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ public class SocketPoolOptions
6767
public TimeSpan DeadTimeout { get; set; } = new TimeSpan(0, 0, 10);
6868
public TimeSpan QueueTimeout { get; set; } = new TimeSpan(0, 0, 0, 0, 100);
6969

70+
public void CheckPoolSize()
71+
{
72+
if (MinPoolSize < 0)
73+
throw new ArgumentOutOfRangeException("value", "MinPoolSize must be >= 0!");
74+
75+
if (MinPoolSize > MaxPoolSize)
76+
throw new ArgumentOutOfRangeException("value", "MinPoolSize must be <= MaxPoolSize!");
77+
78+
if (MaxPoolSize < MinPoolSize)
79+
throw new ArgumentOutOfRangeException("value", "MaxPoolSize must be >= MinPoolSize!");
80+
}
81+
7082
public void CheckTimeout()
7183
{
7284
CheckTimeout(nameof(ConnectionTimeout), ConnectionTimeout);

Enyim.Caching/Configuration/SocketPoolConfiguration.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,7 @@ public class SocketPoolConfiguration : ISocketPoolConfiguration
1919
int ISocketPoolConfiguration.MinPoolSize
2020
{
2121
get { return this.minPoolSize; }
22-
set
23-
{
24-
if (value < 0)
25-
throw new ArgumentOutOfRangeException("value", "MinPoolSize must be >= 0!");
26-
27-
if (value > this.maxPoolSize)
28-
throw new ArgumentOutOfRangeException("value", "MinPoolSize must be <= MaxPoolSize!");
29-
30-
this.minPoolSize = value;
31-
}
22+
set { this.minPoolSize = value; }
3223
}
3324

3425
/// <summary>
@@ -39,13 +30,7 @@ int ISocketPoolConfiguration.MinPoolSize
3930
int ISocketPoolConfiguration.MaxPoolSize
4031
{
4132
get { return this.maxPoolSize; }
42-
set
43-
{
44-
if (value < this.minPoolSize)
45-
throw new ArgumentOutOfRangeException("value", "MaxPoolSize must be >= MinPoolSize!");
46-
47-
this.maxPoolSize = value;
48-
}
33+
set { this.maxPoolSize = value; }
4934
}
5035

5136
TimeSpan ISocketPoolConfiguration.ConnectionTimeout

Enyim.Caching/Enyim.Caching.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>EnyimMemcachedCore is a Memcached client library for .NET Core. Usage: Add services.AddEnyimMemcached(...) and app.UseEnyimMemcached() in Startup. Add IMemcachedClient into constructor.</Description>
5-
<VersionPrefix>2.1.0.1</VersionPrefix>
5+
<VersionPrefix>2.1.0.2</VersionPrefix>
66
<Authors>cnblogs.com</Authors>
77
<TargetFramework>netstandard2.0</TargetFramework>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

0 commit comments

Comments
 (0)