Socket
Socket
Sign inDemoInstall

memcached

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memcached - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

73

lib/memcached.js

@@ -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 : '')

@@ -694,0 +711,0 @@ }});

{
"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.6",
"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;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc