Skip to content

Commit c0e5718

Browse files
Configure the Memcached client with the appropriate user and password for authentication
1 parent f8d462e commit c0e5718

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dotnet/src/dotnetframework/Providers/Cache/GxMemcached/GxMemcached.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ MemcachedClient InitCache()
4747

4848
#if NETCORE
4949
var loggerFactory = new Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory();
50-
MemcachedClientConfiguration config = new MemcachedClientConfiguration(loggerFactory, new MemcachedClientOptions());
51-
#else
52-
MemcachedClientConfiguration config = new MemcachedClientConfiguration();
53-
#endif
50+
MemcachedClientOptions options = new MemcachedClientOptions();
5451
if (!String.IsNullOrEmpty(username) || !String.IsNullOrEmpty(password))
5552
{
56-
config.Authentication.Type = typeof(PlainTextAuthenticator);
57-
config.Authentication.Parameters["userName"] = username;
58-
config.Authentication.Parameters["password"] = password;
53+
options.AddPlainTextAuthenticator(string.Empty, username, password);
5954
}
55+
MemcachedClientConfiguration config = new MemcachedClientConfiguration(loggerFactory, options);
56+
#else
57+
58+
MemcachedClientConfiguration config = new MemcachedClientConfiguration();
59+
#endif
6060
if (!String.IsNullOrEmpty(address))
6161
{
6262
foreach (string host in address.Split(',', ';', ' ')) {

0 commit comments

Comments
 (0)