Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memcache-plus

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memcache-plus - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

35

lib/client.js

@@ -293,22 +293,23 @@ /**

if (this.ready()) {
// First, retrieve the correct connection out of the hashring
var connection = this.connections[this.ring.get(args[0])];
// Run this command
connection[command].apply(connection, args).then(deferred.resolve).catch(deferred.reject);
if (this.disabled) {
return Promise.resolve(null).nodeify(cb);
} else {
this.buffer = this.buffer || new Queue();
this.buffer.push({
cmd: command,
args: args,
key: args[0],
deferred: deferred
});
}
if (this.ready()) {
// First, retrieve the correct connection out of the hashring
var connection = this.connections[this.ring.get(args[0])];
if (this.disabled) {
return Promise.resolve(null).nodeify(cb);
} else {
// Run this command
connection[command].apply(connection, args).then(deferred.resolve).catch(deferred.reject);
} else {
this.buffer = this.buffer || new Queue();
this.buffer.push({
cmd: command,
args: args,
key: args[0],
deferred: deferred
});
}
return deferred.promise.nodeify(cb);

@@ -315,0 +316,0 @@ }

@@ -125,3 +125,2 @@ /**

debug('got data: %s', data.toString());
console.log('got data %s', data.toString());
var deferred = this.queue.peek();

@@ -156,8 +155,3 @@ if (data.toString().substr(0, 5) === 'ERROR') {

this.data = data;
} else if (data.toString().substr(0, 12) === 'SERVER_ERROR') {
this.queue.shift();
deferred.reject(data);
this.data = null;
} else {
console.log('got data: %s', data.toString());
// If this is a response we do not recognize, what to do with it...

@@ -230,3 +224,2 @@ this.queue.shift();

debug('set %s:%s', key, val);
console.log('set %s:%s', key, val);
assert(typeof key === 'string', 'Cannot set in memcache with a not string key');

@@ -254,5 +247,2 @@ assert(key.length < 250, 'Key must be less than 250 characters long');

val = new Buffer(val);
if (val.length > 1048576) {
throw new Error('Value too large to set in memcache');
}

@@ -266,3 +256,2 @@ // First send the metadata for this request

.then(function(data) {
console.log('SET FINISHED: got %s', data.toString());
// data will be a buffer

@@ -274,4 +263,2 @@ if (data.toString() !== 'STORED') {

}
}).catch(function(err) {
console.log('uh oh, something went wrong with set: %s', err);
});

@@ -297,3 +284,2 @@ };

.then(function(data) {
console.log('GET FINISHED: got %s', data.toString());
if (data) {

@@ -300,0 +286,0 @@ return data.toString();

{
"name": "memcache-plus",
"version": "0.1.3",
"version": "0.1.4",
"description": "Better memcache for node",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -124,3 +124,3 @@ require('chai').should();

it('works with very large values', function() {
var key = getKey(), val = chance.word({ length: 1000000 });
var key = getKey(), val = chance.word({ length: 600000 });

@@ -136,8 +136,2 @@ return cache.set(key, val)

it('throws error with enormous values (over memcache limit)', function() {
var key = getKey(), val = chance.word({ length: 1048578 });
expect(function() { cache.set(key, val); }).to.throw('Value too large to set in memcache');
});
it('works fine with special characters', function() {

@@ -444,2 +438,17 @@ var key = getKey(),

describe('Options', function() {
it('can be disabled', function() {
var client = new Client({ disabled: true });
var key = getKey(), val = chance.word();
return client.set(key, val)
.then(function() {
return client.get(key);
})
.then(function(v) {
expect(v).to.be.null;
});
});
});
after(function() {

@@ -446,0 +455,0 @@ var cache = new Client();

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