Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Enyim.Caching/Configuration/MemcachedClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,24 @@ public MemcachedClientConfiguration(
Servers.Add(new DnsEndPoint(server.Address, server.Port));
}
}
SocketPool = options.SocketPool;

SocketPool = new SocketPoolConfiguration();
if (options.SocketPool != null)
{
SocketPool.MinPoolSize = options.SocketPool.MinPoolSize;
_logger.LogInformation($"{nameof(SocketPool.MinPoolSize)}: {SocketPool.MinPoolSize}");
SocketPool.MaxPoolSize = options.SocketPool.MaxPoolSize;
_logger.LogInformation($"{nameof(SocketPool.MaxPoolSize)}: {SocketPool.MaxPoolSize}");
SocketPool.ConnectionTimeout = options.SocketPool.ConnectionTimeout;
_logger.LogInformation($"{nameof(SocketPool.ConnectionTimeout)}: {SocketPool.ConnectionTimeout}");
SocketPool.ReceiveTimeout = options.SocketPool.ReceiveTimeout;
_logger.LogInformation($"{nameof(SocketPool.ReceiveTimeout)}: {SocketPool.ReceiveTimeout}");
SocketPool.DeadTimeout = options.SocketPool.DeadTimeout;
_logger.LogInformation($"{nameof(SocketPool.DeadTimeout)}: {SocketPool.DeadTimeout}");
SocketPool.QueueTimeout = options.SocketPool.QueueTimeout;
_logger.LogInformation($"{nameof(SocketPool.QueueTimeout)}: {SocketPool.QueueTimeout}");
}

Protocol = options.Protocol;

if (options.Authentication != null && !string.IsNullOrEmpty(options.Authentication.Type))
Expand Down
12 changes: 11 additions & 1 deletion Enyim.Caching/Configuration/MemcachedClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MemcachedClientOptions : IOptions<MemcachedClientOptions>
{
public MemcachedProtocol Protocol { get; set; } = MemcachedProtocol.Binary;

public SocketPoolConfiguration SocketPool { get; set; } = new SocketPoolConfiguration();
public SocketPoolOptions SocketPool { get; set; }

public List<Server> Servers { get; set; } = new List<Server>();

Expand Down Expand Up @@ -57,4 +57,14 @@ public class Authentication

public Dictionary<string, string> Parameters { get; set; }
}

public class SocketPoolOptions
{
public int MinPoolSize { get; set; } = 10;
public int MaxPoolSize { get; set; } = 20;
public TimeSpan ConnectionTimeout { get; set; } = new TimeSpan(0, 0, 10);
public TimeSpan ReceiveTimeout { get; set; } = new TimeSpan(0, 0, 10);
public TimeSpan DeadTimeout { get; set; } = new TimeSpan(0, 0, 10);
public TimeSpan QueueTimeout { get; set; } = new TimeSpan(0, 0, 0, 0, 100);
}
}
2 changes: 1 addition & 1 deletion Enyim.Caching/Enyim.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>EnyimMemcachedCore is a Memcached client library for .NET Core. Usage: Add services.AddEnyimMemcached(...) and app.UseEnyimMemcached() in Startup. Add IMemcachedClient into constructor.</Description>
<VersionPrefix>2.0.3</VersionPrefix>
<VersionPrefix>2.0.4</VersionPrefix>
<Authors>cnblogs.com</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
15 changes: 2 additions & 13 deletions SampleWebApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,8 @@ public Startup(IHostingEnvironment env)

public void ConfigureServices(IServiceCollection services)
{
if (IsDevelopment)
{
services.AddEnyimMemcached(options =>
{
options.AddServer("memcached", 11211);
//options.AddPlainTextAuthenticator("", "usename", "password");
});
}
else
{
services.AddEnyimMemcached(Configuration.GetSection("enyimMemcached"));
}
}
services.AddEnyimMemcached(Configuration.GetSection("enyimMemcached"));
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
Expand Down
11 changes: 10 additions & 1 deletion SampleWebApp/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
"Address": "memcached",
"Port": 11211
}
]//,
],
"socketPool": {
"minPoolSize": "5",
"maxPoolSize": "25",
"connectionTimeout": "15",
"receiveTimeout": "15",
"deadTimeout": "15",
"queueTimeout": "150"
}
//,
//"KeyTransformer": "Enyim.Caching.Memcached.SHA1KeyTransformer"
//,
//"Authentication": {
Expand Down