Comparing version 1.3.0 to 1.3.1
@@ -85,8 +85,29 @@ // # MemJS Memcache Client | ||
// An overridable method you can use for determing | ||
// server selection. Should return the server index | ||
// in the list of servers on Client#servers. | ||
// | ||
// Example using node-hashring: | ||
// ~~~~ | ||
// const memjs = require('memjs'); | ||
// const HashRing = require('node-hashring'); | ||
// const servers = ['localhost:11211', 'localhost:11212']; | ||
// // build a map of server addresses to their index in the server list | ||
// const serverMap = {}; | ||
// servers.forEach((server, index) => serverMap[server] = index); | ||
// const client = memjs.Client.create(servers.join(',')); | ||
// // build the hashring | ||
// const hashRing = new HashRing(servers); | ||
// // override the getServer method | ||
// client.getServer = (key) => serverMap[hashRing.findNode(key)]; | ||
// ~~~~ | ||
Client.prototype.getServer = function(key) { | ||
return hashCode(key) % this.servers.length; | ||
}; | ||
// Chooses the server to talk to by hashing the given key. | ||
Client.prototype.server = function(key) { | ||
// TODO(alevy): should use consistent hashing and/or allow swapping hashing | ||
// mechanisms | ||
var total = this.servers.length; | ||
var origIdx = (total > 1) ? (hashCode(key) % total) : 0; | ||
var origIdx = total > 1 ? this.getServer(key) : 0; | ||
var idx = origIdx; | ||
@@ -93,0 +114,0 @@ var serv = this.servers[idx]; |
@@ -153,2 +153,6 @@ var net = require('net'); | ||
self._socket.on('error', function(error) { | ||
self.error(error); | ||
}); | ||
self._socket.on('close', function() { | ||
self.connected = false; | ||
@@ -160,3 +164,2 @@ if (self.timeoutSet) { | ||
self._socket = undefined; | ||
self.error(error); | ||
}); | ||
@@ -163,0 +166,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A memcache client for node using the binary protocol and SASL authentication", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "homepage": "http://github.com/memcachier/memjs", |
@@ -42,3 +42,3 @@ MemJS | ||
memcache server that speaks the binary protocol. Many software repositories | ||
have a version of memcacached available for installation: | ||
have a version of memcached available for installation: | ||
@@ -45,0 +45,0 @@ ### Ubuntu ### |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88494
2345