Skip to content

Commit ed2d066

Browse files
committed
Merge branch 'release/2.2'
2 parents b55b8eb + 59e282c commit ed2d066

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1262
-1625
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ packages/*/
1010
project.lock.json
1111
/publish/*.bat
1212
.vs/
13+
.idea

Enyim.Caching/Configuration/IMemcachedClientConfiguration.cs

+31-31
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,44 @@
55

66
namespace Enyim.Caching.Configuration
77
{
8-
/// <summary>
9-
/// Defines an interface for configuring the <see cref="T:MemcachedClient"/>.
10-
/// </summary>
11-
public interface IMemcachedClientConfiguration
12-
{
13-
/// <summary>
14-
/// Gets a list of <see cref="T:IPEndPoint"/> each representing a Memcached server in the pool.
15-
/// </summary>
16-
IList<DnsEndPoint> Servers { get; }
8+
/// <summary>
9+
/// Defines an interface for configuring the <see cref="T:MemcachedClient"/>.
10+
/// </summary>
11+
public interface IMemcachedClientConfiguration
12+
{
13+
/// <summary>
14+
/// Gets a list of <see cref="T:IPEndPoint"/> each representing a Memcached server in the pool.
15+
/// </summary>
16+
IList<EndPoint> Servers { get; }
1717

18-
/// <summary>
19-
/// Gets the configuration of the socket pool.
20-
/// </summary>
21-
ISocketPoolConfiguration SocketPool { get; }
18+
/// <summary>
19+
/// Gets the configuration of the socket pool.
20+
/// </summary>
21+
ISocketPoolConfiguration SocketPool { get; }
2222

23-
/// <summary>
24-
/// Gets the authentication settings.
25-
/// </summary>
26-
IAuthenticationConfiguration Authentication { get; }
23+
/// <summary>
24+
/// Gets the authentication settings.
25+
/// </summary>
26+
IAuthenticationConfiguration Authentication { get; }
2727

28-
/// <summary>
29-
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedKeyTransformer"/> instance which will be used to convert item keys for Memcached.
30-
/// </summary>
31-
IMemcachedKeyTransformer CreateKeyTransformer();
28+
/// <summary>
29+
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedKeyTransformer"/> instance which will be used to convert item keys for Memcached.
30+
/// </summary>
31+
IMemcachedKeyTransformer CreateKeyTransformer();
3232

33-
/// <summary>
34-
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedNodeLocator"/> instance which will be used to assign items to Memcached nodes.
35-
/// </summary>
36-
IMemcachedNodeLocator CreateNodeLocator();
33+
/// <summary>
34+
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedNodeLocator"/> instance which will be used to assign items to Memcached nodes.
35+
/// </summary>
36+
IMemcachedNodeLocator CreateNodeLocator();
3737

38-
/// <summary>
39-
/// Creates an <see cref="T:Enyim.Caching.Memcached.ITranscoder"/> instance which will be used to serialize or deserialize items.
40-
/// </summary>
41-
ITranscoder CreateTranscoder();
38+
/// <summary>
39+
/// Creates an <see cref="T:Enyim.Caching.Memcached.ITranscoder"/> instance which will be used to serialize or deserialize items.
40+
/// </summary>
41+
ITranscoder CreateTranscoder();
4242

43-
IServerPool CreatePool();
43+
IServerPool CreatePool();
4444

45-
}
45+
}
4646
}
4747

4848
#region [ License information ]

Enyim.Caching/Configuration/ISocketPoolConfiguration.cs

+63-61
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,75 @@
33

44
namespace Enyim.Caching.Configuration
55
{
6-
/// <summary>
7-
/// Defines an interface for configuring the socket pool for the <see cref="T:MemcachedClient"/>.
8-
/// </summary>
9-
public interface ISocketPoolConfiguration
10-
{
11-
/// <summary>
12-
/// Gets or sets a value indicating the minimum amount of sockets per server in the socket pool.
13-
/// </summary>
14-
/// <returns>The minimum amount of sockets per server in the socket pool.</returns>
15-
int MinPoolSize
16-
{
17-
get;
18-
set;
19-
}
6+
/// <summary>
7+
/// Defines an interface for configuring the socket pool for the <see cref="T:MemcachedClient"/>.
8+
/// </summary>
9+
public interface ISocketPoolConfiguration
10+
{
11+
/// <summary>
12+
/// Gets or sets a value indicating the minimum amount of sockets per server in the socket pool.
13+
/// </summary>
14+
/// <returns>The minimum amount of sockets per server in the socket pool.</returns>
15+
int MinPoolSize
16+
{
17+
get;
18+
set;
19+
}
2020

21-
/// <summary>
22-
/// Gets or sets a value indicating the maximum amount of sockets per server in the socket pool.
23-
/// </summary>
24-
/// <returns>The maximum amount of sockets per server in the socket pool.</returns>
25-
int MaxPoolSize
26-
{
27-
get;
28-
set;
29-
}
21+
/// <summary>
22+
/// Gets or sets a value indicating the maximum amount of sockets per server in the socket pool.
23+
/// </summary>
24+
/// <returns>The maximum amount of sockets per server in the socket pool.</returns>
25+
int MaxPoolSize
26+
{
27+
get;
28+
set;
29+
}
3030

31-
/// <summary>
32-
/// Gets or sets a value that specifies the amount of time after which the connection attempt will fail.
33-
/// </summary>
34-
/// <returns>The value of the connection timeout.</returns>
35-
TimeSpan ConnectionTimeout
36-
{
37-
get;
38-
set;
39-
}
31+
/// <summary>
32+
/// Gets or sets a value that specifies the amount of time after which the connection attempt will fail.
33+
/// </summary>
34+
/// <returns>The value of the connection timeout.</returns>
35+
TimeSpan ConnectionTimeout
36+
{
37+
get;
38+
set;
39+
}
4040

41-
/// <summary>
42-
/// Gets or sets a value that specifies the amount of time after which the getting a connection from the pool will fail.
43-
/// </summary>
44-
/// <returns>The value of the queue timeout.</returns>
45-
TimeSpan QueueTimeout
46-
{
47-
get;
48-
set;
49-
}
41+
/// <summary>
42+
/// Gets or sets a value that specifies the amount of time after which the getting a connection from the pool will fail.
43+
/// </summary>
44+
/// <returns>The value of the queue timeout.</returns>
45+
TimeSpan QueueTimeout
46+
{
47+
get;
48+
set;
49+
}
5050

51-
/// <summary>
52-
/// Gets or sets a value that specifies the amount of time after which receiving data from the socket will fail.
53-
/// </summary>
54-
/// <returns>The value of the receive timeout.</returns>
55-
TimeSpan ReceiveTimeout
56-
{
57-
get;
58-
set;
59-
}
51+
/// <summary>
52+
/// Gets or sets a value that specifies the amount of time after which receiving data from the socket will fail.
53+
/// </summary>
54+
/// <returns>The value of the receive timeout.</returns>
55+
TimeSpan ReceiveTimeout
56+
{
57+
get;
58+
set;
59+
}
6060

61-
/// <summary>
62-
/// Gets or sets a value that specifies the amount of time after which an unresponsive (dead) server will be checked if it is working.
63-
/// </summary>
64-
/// <returns>The value of the dead timeout.</returns>
65-
TimeSpan DeadTimeout
66-
{
67-
get;
68-
set;
69-
}
61+
/// <summary>
62+
/// Gets or sets a value that specifies the amount of time after which an unresponsive (dead) server will be checked if it is working.
63+
/// </summary>
64+
/// <returns>The value of the dead timeout.</returns>
65+
TimeSpan DeadTimeout
66+
{
67+
get;
68+
set;
69+
}
7070

71-
INodeFailurePolicyFactory FailurePolicyFactory { get; set; }
72-
}
71+
TimeSpan InitPoolTimeout { get; set; }
72+
73+
INodeFailurePolicyFactory FailurePolicyFactory { get; set; }
74+
}
7375
}
7476

7577
#region [ License information ]

Enyim.Caching/Configuration/MemcachedClientConfiguration.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public MemcachedClientConfiguration(
8080

8181
SocketPool.QueueTimeout = options.SocketPool.QueueTimeout;
8282
_logger.LogInformation($"{nameof(SocketPool.QueueTimeout)}: {SocketPool.QueueTimeout}");
83+
84+
SocketPool.InitPoolTimeout = options.SocketPool.InitPoolTimeout;
8385
}
8486

8587
Protocol = options.Protocol;
@@ -172,30 +174,29 @@ public MemcachedClientConfiguration(
172174

173175
private void ConfigureServers(MemcachedClientOptions options)
174176
{
175-
Servers = new List<DnsEndPoint>();
177+
Servers = new List<EndPoint>();
176178
foreach (var server in options.Servers)
177179
{
178180
if (!IPAddress.TryParse(server.Address, out var address))
179181
{
180-
var ip = Dns.GetHostAddresses(server.Address)
181-
.FirstOrDefault(i => i.AddressFamily == AddressFamily.InterNetwork)?.ToString();
182+
address = Dns.GetHostAddresses(server.Address)
183+
.FirstOrDefault(i => i.AddressFamily == AddressFamily.InterNetwork);
182184

183-
if (ip == null)
185+
if (address == null)
184186
{
185187
_logger.LogError($"Could not resolve host '{server.Address}'.");
186188
}
187189
else
188190
{
189-
_logger.LogInformation($"Memcached server address - {server.Address }({ip}):{server.Port}");
190-
server.Address = ip;
191+
_logger.LogInformation($"Memcached server address - {address}");
191192
}
192193
}
193194
else
194195
{
195196
_logger.LogInformation($"Memcached server address - {server.Address }:{server.Port}");
196197
}
197198

198-
Servers.Add(new DnsEndPoint(server.Address, server.Port));
199+
Servers.Add(new IPEndPoint(address, server.Port));
199200
}
200201
}
201202

@@ -221,7 +222,7 @@ public void AddServer(string host, int port)
221222
/// <summary>
222223
/// Gets a list of <see cref="T:IPEndPoint"/> each representing a Memcached server in the pool.
223224
/// </summary>
224-
public IList<DnsEndPoint> Servers { get; private set; }
225+
public IList<EndPoint> Servers { get; private set; }
225226

226227
/// <summary>
227228
/// Gets the configuration of the socket pool.
@@ -278,7 +279,7 @@ public ITranscoder Transcoder
278279

279280
#region [ interface ]
280281

281-
IList<System.Net.DnsEndPoint> IMemcachedClientConfiguration.Servers
282+
IList<EndPoint> IMemcachedClientConfiguration.Servers
282283
{
283284
get { return this.Servers; }
284285
}

Enyim.Caching/Configuration/MemcachedClientOptions.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void AddServer(string address, int port)
3030
Servers.Add(new Server { Address = address, Port = port });
3131
}
3232

33-
public void AddDefaultServer() => AddServer("memcached", 11211);
33+
public void AddDefaultServer() => AddServer("memcached", 11211);
3434

3535
public void AddPlainTextAuthenticator(string zone, string userName, string password)
3636
{
@@ -62,12 +62,13 @@ public class Authentication
6262

6363
public class SocketPoolOptions
6464
{
65-
public int MinPoolSize { get; set; } = 10;
66-
public int MaxPoolSize { get; set; } = 20;
65+
public int MinPoolSize { get; set; } = 5;
66+
public int MaxPoolSize { get; set; } = 100;
6767
public TimeSpan ConnectionTimeout { get; set; } = new TimeSpan(0, 0, 10);
6868
public TimeSpan ReceiveTimeout { get; set; } = new TimeSpan(0, 0, 10);
6969
public TimeSpan DeadTimeout { get; set; } = new TimeSpan(0, 0, 10);
7070
public TimeSpan QueueTimeout { get; set; } = new TimeSpan(0, 0, 0, 0, 100);
71+
public TimeSpan InitPoolTimeout { get; set; } = new TimeSpan(0, 1, 0);
7172

7273
public void CheckPoolSize()
7374
{

0 commit comments

Comments
 (0)