Comparing version 0.0.5 to 0.0.7
@@ -27,3 +27,3 @@ var EventEmitter = require('events').EventEmitter | ||
// Parse down the connection arguments | ||
// Parse down the connection arguments | ||
switch (Object.prototype.toString.call(args)){ | ||
@@ -61,3 +61,3 @@ case '[object String]': | ||
, algorithm: 'crc32' // hashing algorithm that is used for key mapping | ||
, algorithm: 'crc32' // hashing algorithm that is used for key mapping | ||
@@ -140,3 +140,3 @@ , poolSize: 10 // maximal parallel connections | ||
// Creates a multi stream, so it's easier to query agains | ||
// multiple memcached servers. | ||
// multiple memcached servers. | ||
memcached.multi = function memcachedMulti(keys, callback){ | ||
@@ -150,5 +150,8 @@ var map = {} | ||
// or just gives all servers if we don't have keys | ||
if (keys){ | ||
if (keys) { | ||
keys.forEach(function fetchMultipleServers(key){ | ||
var server = memcached.HashRing.getNode(key); | ||
var server = memcached.servers.length === 1 | ||
? memcached.servers[0] | ||
: memcached.HashRing.getNode(key); | ||
if (map[server]){ | ||
@@ -160,2 +163,3 @@ map[server].push(key); | ||
}); | ||
// store the servers | ||
@@ -173,3 +177,3 @@ servers = Object.keys(map); | ||
// Executes the command on the net.Stream, if no server is supplied it will use the query.key to get | ||
// Executes the command on the net.Stream, if no server is supplied it will use the query.key to get | ||
// the server from the HashRing | ||
@@ -179,5 +183,5 @@ memcached.command = function memcachedCommand(queryCompiler, server){ | ||
var query = queryCompiler() | ||
, redundancy = this.redundancy && this.redundancy < this.servers.length | ||
, queryRedundancy = query.redundancyEnabled | ||
, memcached = this; | ||
, redundancy = this.redundancy && this.redundancy < this.servers.length | ||
, queryRedundancy = query.redundancyEnabled | ||
, memcached = this; | ||
@@ -187,4 +191,17 @@ // validate the arguments | ||
// fetch servers | ||
server = server ? server : redundancy && queryRedundancy ? (redundancy = this.HashRing.createRange(query.key, (this.redundancy + 1), true)).shift() : this.HashRing.getNode(query.key); | ||
// try to find the correct server for this query | ||
if (!server) { | ||
// no need to do a hashring lookup if we only have one server assigned to | ||
// us | ||
if (this.servers.length === 1) { | ||
server = this.servers[0]; | ||
} else { | ||
if (redundancy && queryRedundancy) { | ||
redundancy = this.HashRing.createRange(query.key, (this.redundancy + 1), true); | ||
server = redundancy.shift(); | ||
} else { | ||
server = this.HashRing.getNode(query.key); | ||
} | ||
} | ||
} | ||
@@ -327,3 +344,3 @@ // check if the server is still alive | ||
return [BUFFER, false] | ||
return [BUFFER, false] | ||
} | ||
@@ -333,3 +350,3 @@ , 'INCRDECR': function(tokens){ return [CONTINUE, +tokens[1]] } | ||
queue.push([tokens[1], /^\d+$/.test(tokens[2]) ? +tokens[2] : tokens[2]]); | ||
return [BUFFER, true] | ||
return [BUFFER, true] | ||
} | ||
@@ -366,3 +383,3 @@ , 'VERSION': function(tokens, dataSet){ | ||
// Fill the object | ||
// Fill the object | ||
resultSet.forEach(function(statSet){ | ||
@@ -384,3 +401,3 @@ response[statSet[0]] = statSet[1]; | ||
// Fill the object | ||
// Fill the object | ||
resultSet.forEach(function(statSet){ | ||
@@ -401,3 +418,3 @@ var identifier = statSet[0].split(':'); | ||
// Fill the object | ||
// Fill the object | ||
resultSet.forEach(function(statSet){ | ||
@@ -437,3 +454,3 @@ var identifier = statSet[0].split(':'); | ||
this.rawDataReceived(S, S.bufferArray = S.bufferArray.concat(chunks)); | ||
} | ||
} | ||
}; | ||
@@ -443,3 +460,3 @@ | ||
// identifiers. Once we have found one, we will send it to the dedicated parsers that will transform | ||
// the data in a human readable format, deciding if we should queue it up, or send it to a callback fn. | ||
// the data in a human readable format, deciding if we should queue it up, or send it to a callback fn. | ||
memcached.rawDataReceived = function rawDataReceived(S){ | ||
@@ -464,3 +481,3 @@ var queue = [] | ||
// special case for value, it's required that it has a second response! | ||
// add the token back, and wait for the next response, we might be handling a big | ||
// add the token back, and wait for the next response, we might be handling a big | ||
// ass response here. | ||
@@ -502,3 +519,3 @@ if (tokenSet[0] == 'VALUE' && S.bufferArray.indexOf('END') == -1){ | ||
private.resultParsers[metaData.type] ? private.resultParsers[metaData.type].call(S, resultSet, err) : | ||
!Array.isArray(queue) || queue.length > 1 ? queue : queue[0] | ||
!Array.isArray(queue) || queue.length > 1 ? queue : queue[0] | ||
); | ||
@@ -536,3 +553,3 @@ } | ||
// check if we need to remove an empty item from the array, as splitting on /r/n might cause an empty | ||
// item at the end.. | ||
// item at the end.. | ||
if (S.bufferArray[0] === '') S.bufferArray.shift(); | ||
@@ -548,3 +565,3 @@ }; | ||
}; | ||
// This is where the actual Memcached API layer begins: | ||
@@ -582,3 +599,3 @@ memcached.get = function get(key, callback){ | ||
// handle multiple responses and cache them untill we receive all. | ||
// handle multiple responses and cache them untill we receive all. | ||
, handle = function(err, results){ | ||
@@ -607,6 +624,6 @@ if (err) errors.push(err); | ||
// As all command nearly use the same syntax we are going to proxy them all to this | ||
// As all command nearly use the same syntax we are going to proxy them all to this | ||
// function to ease maintenance. This is possible because most set commands will use the same | ||
// syntax for the Memcached server. Some commands do not require a lifetime and a flag, but the | ||
// memcached server is smart enough to ignore those. | ||
// memcached server is smart enough to ignore those. | ||
private.setters = function setters(type, validate, key, value, lifetime, callback, cas){ | ||
@@ -641,4 +658,4 @@ var flag = 0 | ||
, command: [type, key, flag, lifetime, length].join(' ') + | ||
(cas ? ' ' + cas : '') + | ||
(noreply ? NOREPLY : '') + | ||
(cas ? ' ' + cas : '') + | ||
(noreply ? NOREPLY : '') + | ||
LINEBREAK + value | ||
@@ -691,3 +708,3 @@ }}); | ||
, redundancyEnabled: true | ||
, command: 'delete ' + key + | ||
, command: 'delete ' + key + | ||
(noreply ? NOREPLY : '') | ||
@@ -729,3 +746,3 @@ }}); | ||
memcached.version = Utils.curry(false, private.singles, 'version'); | ||
memcached.flush = Utils.curry(false, private.singles, 'flush_all'); | ||
memcached.flush = memcached.flushAll = Utils.curry(false, private.singles, 'flush_all'); | ||
memcached.stats = Utils.curry(false, private.singles, 'stats'); | ||
@@ -736,2 +753,8 @@ memcached.settings = Utils.curry(false, private.singles, 'stats settings'); | ||
// aliases | ||
memcached.flushAll = memcached.flush; | ||
memcached.settings = memcached.statsSettings; | ||
memcached.slabs = memcached.statsSlabs; | ||
memcached.items = memcached.statsItems; | ||
// You need to use the items dump to get the correct server and slab settings | ||
@@ -738,0 +761,0 @@ // see simple_cachedump.js for an example |
{ | ||
"name": "memcached" | ||
, "version": "0.0.5" | ||
, "author": "Arnout Kazemier" | ||
, "description": "A fully featured Memcached API client, supporting both single and clustered Memcached servers through consistent hashing and failover/failure. Memcached is rewrite of nMemcached, which will be deprecated in the near future." | ||
, "main": "index" | ||
, "keywords":[ | ||
"memcached" | ||
, "client" | ||
, "hashing" | ||
, "failover" | ||
, "cluster" | ||
, "nMemcached" | ||
, "memcache" | ||
, "cache" | ||
, "nosql" | ||
, "membase" | ||
, "InnoDB memcached API" | ||
"name": "memcached", | ||
"version": "0.0.7", | ||
"author": { | ||
"name": "Arnout Kazemier" | ||
}, | ||
"description": "A fully featured Memcached API client, supporting both single and clustered Memcached servers through consistent hashing and failover/failure. Memcached is rewrite of nMemcached, which will be deprecated in the near future.", | ||
"main": "index", | ||
"keywords": [ | ||
"memcached", | ||
"client", | ||
"hashing", | ||
"failover", | ||
"cluster", | ||
"nMemcached", | ||
"memcache", | ||
"cache", | ||
"nosql", | ||
"membase", | ||
"InnoDB memcached API" | ||
], | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Arnout Kazemier", | ||
"email": "info@3rd-Eden.com", | ||
"url": "http://www.3rd-Eden.com" | ||
} | ||
], | ||
"license": { | ||
"type": "MIT", | ||
"url": "http://github.com/3rd-Eden/node-memcached/blob/master/LICENSE" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/3rd-Eden/node-memcached.git" | ||
}, | ||
"dependencies": { | ||
"hashring": "0.0.x" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Arnout Kazemier", | ||
"email": "info@3rd-Eden.com" | ||
}, | ||
{ | ||
"name": "Anton Onyshchenko" | ||
} | ||
] | ||
, "directories": { | ||
"lib": "./lib" | ||
} | ||
, "maintainers": [{ | ||
"name":"Arnout Kazemier" | ||
, "email":"info@3rd-Eden.com" | ||
, "web":"http://www.3rd-Eden.com" | ||
}] | ||
, "license": { | ||
"type": "MIT" | ||
, "url": "http://github.com/3rd-Eden/node-memcached/blob/master/LICENSE" | ||
} | ||
, "repository": { | ||
"type": "git" | ||
, "url" : "http://github.com/3rd-Eden/node-memcached.git" | ||
} | ||
, "dependencies": { | ||
"hashring": "" | ||
} | ||
} |
@@ -77,3 +77,3 @@ #Memcached | ||
``` js | ||
var Memcached = require( 'memcached' ).Client; | ||
var Memcached = require('memcached'); | ||
// all global configurations should be applied to the .config object of the Client. | ||
@@ -80,0 +80,0 @@ Memcached.config.poolSize = 25; |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
5
4
256630
49
1352
+ Addedbisection@0.0.3(transitive)
+ Addedhashring@0.0.8(transitive)
- Removedconnection-parse@0.0.7(transitive)
- Removedhashring@3.2.0(transitive)
Updatedhashring@0.0.x