Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default_port option for compatibility with libmemcached. #23

Merged
merged 1 commit into from
Sep 22, 2014

Conversation

rcoup
Copy link
Contributor

@rcoup rcoup commented Sep 22, 2014

libmemcached ignores the default memcached port when hashing via ketama_weighted:
http://bazaar.launchpad.net/~tangent-trunk/libmemcached/1.2/view/head:/libmemcached/hosts.cc#L293

So, ['1.1.1.1:11211', '2.2.2.2:11211', '1.1.1.1:11212'] builds a an identical continuum to ['1.1.1.1', '2.2.2.2', '1.1.1.1:11212'] in libmemcached (using ketama_weighted). In node-hashring the port is always hashed, so there is an incompatibility if you specify :11211 in your node-hashring server list.

To match the libmemcached behaviour, I added a default_port option, and if the server port matches the default port it isn't used in the continuum hash. ie:

new HashRing(servers, 'md5', {default_port:11211})

libmemcached ignores the default memcached port when hashing via ketama_weighted:
http://bazaar.launchpad.net/~tangent-trunk/libmemcached/1.2/view/head:/libmemcached/hosts.cc#L293

To match the behaviour, use `new HashRing(hosts, 'md5', {default_port:11211})`
@3rd-Eden
Copy link
Owner

@rcoup Thanks a lot for catching this and providing me with a pull request and a test.

You da real mvp

3rd-Eden added a commit that referenced this pull request Sep 22, 2014
Add `default_port` option for compatibility with libmemcached.
@3rd-Eden 3rd-Eden merged commit b5969de into 3rd-Eden:master Sep 22, 2014
rcoup added a commit to rcoup/node-memcached that referenced this pull request Sep 22, 2014
When using ketama compatibility, utilise the `default_port` option from 3rd-Eden/node-hashring#23
@rcoup
Copy link
Contributor Author

rcoup commented Sep 22, 2014

It was a complete bugger to track down 😭, thanks for the quick merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants