memcache-plus
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -40,2 +40,3 @@ /** | ||
autodiscover: false, | ||
disabled: false, | ||
hosts: null, | ||
@@ -310,5 +311,9 @@ reconnect: true | ||
return deferred.promise.nodeify(cb); | ||
if (this.disabled) { | ||
return Promise.resolve(null).nodeify(cb); | ||
} else { | ||
return deferred.promise.nodeify(cb); | ||
} | ||
}; | ||
module.exports = Client; |
@@ -125,2 +125,3 @@ /** | ||
debug('got data: %s', data.toString()); | ||
console.log('got data %s', data.toString()); | ||
var deferred = this.queue.peek(); | ||
@@ -155,3 +156,8 @@ 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... | ||
@@ -224,2 +230,3 @@ 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'); | ||
@@ -247,2 +254,5 @@ 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'); | ||
} | ||
@@ -256,2 +266,3 @@ // First send the metadata for this request | ||
.then(function(data) { | ||
console.log('SET FINISHED: got %s', data.toString()); | ||
// data will be a buffer | ||
@@ -263,2 +274,4 @@ if (data.toString() !== 'STORED') { | ||
} | ||
}).catch(function(err) { | ||
console.log('uh oh, something went wrong with set: %s', err); | ||
}); | ||
@@ -284,2 +297,3 @@ }; | ||
.then(function(data) { | ||
console.log('GET FINISHED: got %s', data.toString()); | ||
if (data) { | ||
@@ -286,0 +300,0 @@ return data.toString(); |
{ | ||
"name": "memcache-plus", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Better memcache for node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -87,3 +87,2 @@ require('chai').should(); | ||
var cache; | ||
before(function() { | ||
@@ -126,3 +125,3 @@ cache = new Client(); | ||
it('works with very large values', function() { | ||
var key = getKey(), val = chance.word({ length: 600000 }); | ||
var key = getKey(), val = chance.word({ length: 1000000 }); | ||
@@ -138,2 +137,8 @@ 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() { | ||
@@ -232,5 +237,5 @@ var key = getKey(), | ||
describe('get to key that does not exist returns error', function() { | ||
describe('get to key that does not exist returns null', function() { | ||
it('with Promise', function() { | ||
return cache.get(chance.word()) | ||
return cache.get(chance.guid()) | ||
.then(function(v) { | ||
@@ -237,0 +242,0 @@ expect(v).to.be.null; |
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
43662
1058