cnblogs / EnyimMemcachedCore

.NET Memcached client. Available on https://www.nuget.org/packages/EnyimMemcachedCore
Apache License 2.0
162 stars 45 forks source link

Connecting with Kubernetes namespace DNS. #226

Closed ArgenDevCorp closed 4 months ago

ArgenDevCorp commented 6 months ago

Hello, im having issues with the connection to memcached. I have a pod containing memcached in kubernetes. The problem comes when the node where this pod is located moves, and therefore the IP of my memcached pod changes.

Im not using fixed IP, im using a namespace "memcached-prod", but in my microservices, whenever the IP changes, it keeps retrying on the old IP and dont look up to the DNS again.

Is there any configuration that im missing or this library its not think for dynamic ip's?

This is how i do the configuration:

        public void Register(IServiceCollection serviceCollection)
        {    
            serviceCollection.AddSingleton<ICachingService, CachingService>();
            serviceCollection.AddEnyimMemcached(o =>
            {
                o.Servers = new List<Server>
                {
                   new Server { Address = _host, Port = _port}
                };

                if (!string.IsNullOrEmpty(_user) && !string.IsNullOrEmpty(_pass))
                {
                    o.AddPlainTextAuthenticator(string.Empty, _user, _pass);                  
                }

            });
        }

Thanks!