diff --git a/sample/SampleWebApp/appsettings.example.json b/sample/SampleWebApp/appsettings.example.json index 363d6d63..d0e4f35b 100644 --- a/sample/SampleWebApp/appsettings.example.json +++ b/sample/SampleWebApp/appsettings.example.json @@ -7,12 +7,12 @@ } ], "SocketPool": { - "minPoolSize": 5, - "maxPoolSize": 25, - "connectionTimeout": "00:00:15", - "receiveTimeout": "00:00:15", - "deadTimeout": "00:00:15", - "queueTimeout": "00:00:00.150" + "MinPoolSize": 5, + "MaxPoolSize": 25, + "ConnectionTimeout": "00:00:15", + "ReceiveTimeout": "00:00:15", + "DeadTimeout": "00:00:15", + "QueueTimeout": "00:00:00.150" }, "SuppressException": false, "UseSslStream": false, @@ -23,14 +23,14 @@ "Authentication": { "Type": "Enyim.Caching.Memcached.PlainTextAuthenticator", "Parameters": { - "zone": "", - "userName": "username", - "password": "password" + "Zone": "", + "UserName": "username", + "Password": "password" } } }, - "postbodyMemcached": { + "PostbodyMemcached": { "Servers": [ { "Address": "memcached", diff --git a/sample/SampleWebApp/appsettings.json b/sample/SampleWebApp/appsettings.json index e9529843..37cfce63 100644 --- a/sample/SampleWebApp/appsettings.json +++ b/sample/SampleWebApp/appsettings.json @@ -6,20 +6,20 @@ "Port": 11211 } ], - "socketPool": { - "minPoolSize": 5, - "maxPoolSize": 10, - "connectionTimeout": "00:00:15", - "receiveTimeout": "00:00:15", - "deadTimeout": "00:00:15", - "queueTimeout": "00:00:00.150" + "SocketPool": { + "MinPoolSize": 5, + "MaxPoolSize": 10, + "ConnectionTimeout": "00:00:15", + "ReceiveTimeout": "00:00:15", + "DeadTimeout": "00:00:15", + "QueueTimeout": "00:00:00.150" }, - "suppressException": false, + "SuppressException": false, "UseLegacyNodeLocator": false, "Transcoder": "MessagePackTranscoder" }, - "postbodyMemcached": { + "PostbodyMemcached": { "Servers": [ { "Address": "memcached", diff --git a/src/Enyim.Caching/Configuration/MemcachedClientConfiguration.cs b/src/Enyim.Caching/Configuration/MemcachedClientConfiguration.cs index cf042efe..b1702981 100755 --- a/src/Enyim.Caching/Configuration/MemcachedClientConfiguration.cs +++ b/src/Enyim.Caching/Configuration/MemcachedClientConfiguration.cs @@ -108,25 +108,24 @@ public MemcachedClientConfiguration( var authenticationType = Type.GetType(options.Authentication.Type); if (authenticationType != null) { - _logger.LogDebug($"Authentication type is {authenticationType}."); + _logger.LogDebug("Authentication type is {authenticationType}.", authenticationType); Authentication = new AuthenticationConfiguration(); Authentication.Type = authenticationType; foreach (var parameter in options.Authentication.Parameters) { Authentication.Parameters[parameter.Key] = parameter.Value; - _logger.LogDebug($"Authentication {parameter.Key} is '{parameter.Value}'."); + _logger.LogDebug("Authentication {Key} is '{Value}'.", parameter.Key, parameter.Value); } } else { - _logger.LogError($"Unable to load authentication type {options.Authentication.Type}."); + _logger.LogError("Unable to load authentication type '{AuthenticationType}'.", options.Authentication.Type); } } catch (Exception ex) { - _logger.LogError(new EventId(), ex, - $"Unable to load authentication type {options.Authentication.Type}."); + _logger.LogError(ex, "Unable to load authentication type '{AuthenticationType}'.", options.Authentication.Type); } } @@ -145,18 +144,18 @@ public MemcachedClientConfiguration( if (keyTransformerType != null) { KeyTransformer = Activator.CreateInstance(keyTransformerType) as IMemcachedKeyTransformer; - _logger.LogDebug($"Use '{options.KeyTransformer}' KeyTransformer"); + _logger.LogDebug("Use '{KeyTransformer}' KeyTransformer", options.KeyTransformer); } } catch (Exception ex) { - _logger.LogError(new EventId(), ex, $"Unable to load '{options.KeyTransformer}' KeyTransformer"); + _logger.LogError(ex, "Unable to load '{KeyTransformer}' KeyTransformer", options.KeyTransformer); } } else if (keyTransformer != null) { _keyTransformer = keyTransformer; - _logger.LogDebug($"Use KeyTransformer Type : '{keyTransformer}'"); + _logger.LogDebug("Use KeyTransformer Type : '{keyTransformer}'", keyTransformer); } if (!string.IsNullOrEmpty(options.Transcoder)) @@ -176,18 +175,18 @@ public MemcachedClientConfiguration( if (transcoderType != null) { Transcoder = Activator.CreateInstance(transcoderType) as ITranscoder; - _logger.LogDebug($"Use '{options.Transcoder}'"); + _logger.LogDebug("Use '{Transcoder}'", options.Transcoder); } } catch (Exception ex) { - _logger.LogError(new EventId(), ex, $"Unable to load '{options.Transcoder}'"); + _logger.LogError(new EventId(), ex, "Unable to load '{Transcoder}'", Transcoder); } } else if (transcoder != null) { _transcoder = transcoder; - _logger.LogDebug($"Use Transcoder Type : '{transcoder}'"); + _logger.LogDebug("Use Transcoder Type : '{transcoder}'", transcoder); } if (options.NodeLocatorFactory != null) diff --git a/src/Enyim.Caching/Configuration/MemcachedClientOptionsT.cs b/src/Enyim.Caching/Configuration/MemcachedClientOptionsT.cs new file mode 100644 index 00000000..da05e73f --- /dev/null +++ b/src/Enyim.Caching/Configuration/MemcachedClientOptionsT.cs @@ -0,0 +1,4 @@ +namespace Enyim.Caching.Configuration; + +public class MemcachedClientOptions : MemcachedClientOptions +{ } diff --git a/src/Enyim.Caching/EnyimMemcachedServiceCollectionExtensions.cs b/src/Enyim.Caching/EnyimMemcachedServiceCollectionExtensions.cs index a7477a92..be553e13 100644 --- a/src/Enyim.Caching/EnyimMemcachedServiceCollectionExtensions.cs +++ b/src/Enyim.Caching/EnyimMemcachedServiceCollectionExtensions.cs @@ -135,7 +135,7 @@ public static IServiceCollection AddEnyimMemcached( } return services.AddEnyimMemcached( - s => s.AddOptions().BindConfiguration(sectionKey)); + s => s.AddOptions>().BindConfiguration(sectionKey)); } public static IServiceCollection AddEnyimMemcached( @@ -154,7 +154,7 @@ public static IServiceCollection AddEnyimMemcached( } return services.AddEnyimMemcached( - s => s.Configure(configuration.GetSection(sectionKey))); + s => s.Configure>(configuration.GetSection(sectionKey))); } #endif @@ -171,7 +171,7 @@ public static IServiceCollection AddEnyimMemcached( services.TryAddSingleton>(sp => { var loggerFactory = sp.GetRequiredService(); - var options = sp.GetRequiredService>(); + var options = sp.GetRequiredService>>(); var conf = new MemcachedClientConfiguration(loggerFactory, options); return new MemcachedClient(loggerFactory, conf); }); diff --git a/src/Enyim.Caching/IMemcachedClient.cs b/src/Enyim.Caching/IMemcachedClient.cs index d67aaaa6..b355b132 100644 --- a/src/Enyim.Caching/IMemcachedClient.cs +++ b/src/Enyim.Caching/IMemcachedClient.cs @@ -1,8 +1,8 @@ -using System; -using Enyim.Caching.Memcached; +using Enyim.Caching.Memcached; +using Enyim.Caching.Memcached.Results; +using System; using System.Collections.Generic; using System.Threading.Tasks; -using Enyim.Caching.Memcached.Results; namespace Enyim.Caching {