private void Add(Caching.Faster.Abstractions.Worker node, bool updateKeyArray)
        {
            Logger.LogInformation($"Joining {node.Name} with endpoint {node.Address} on port {node.Port}");

            if (!channels.TryGetValue(node.Address, out _))
            {
                channels.Add(node.Address, new GrpcWorkerClient(new Channel(node.Address, node.Port, ChannelCredentials.Insecure)));

                Logger.LogInformation($"Worker {node.Name} joined.");
            }

            for (var i = 0; i < _replicate; i++)
            {
                var h    = $"{node.Name}{node.Port}{node.Address}{i}".GetConsistentHashCode();
                var hash = BetterHash($"{h}");
                circle[hash] = node;
            }

            if (updateKeyArray)
            {
                _orderedKeys = circle.Keys.ToArray();
            }
        }
        public void Remove(Caching.Faster.Abstractions.Worker node)
        {
            Logger.LogInformation($"Joining {node.Name} with endpoint {node.Address} on port {node.Port}");

            if (channels.TryGetValue(node.Address, out _))
            {
                channels.Remove(node.Address);

                Logger.LogInformation($"Worker {node.Name} removed.");
            }

            for (var i = 0; i < _replicate; i++)
            {
                var h = $"{node.Name}{node.Port}{node.Address}{i}".GetConsistentHashCode();

                var hash = BetterHash($"{h}");

                if (!circle.Remove(hash))
                {
                    throw new Exception("cannot remove a node that not added");
                }
            }
            _orderedKeys = circle.Keys.ToArray();
        }
 public void Add(Caching.Faster.Abstractions.Worker node)
 {
     Add(node, true);
 }
 // need to move this to another class
 public GrpcWorkerClient GetGrpcChannel(Caching.Faster.Abstractions.Worker key)
 {
     return(channels[key.Address]);
 }