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

memjs

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memjs - npm Package Compare versions

Comparing version 0.10.2 to 1.0.0-rc.1

docs/_redirects

83

lib/memjs/memjs.js

@@ -39,3 +39,3 @@ // # MemJS Memcache Client

// is 60 seconds.
//
//
// ~~~~

@@ -54,3 +54,3 @@ // log(msg1[, msg2[, msg3[...]]])

// * `keepAlive` whether to enable keep-alive functionality. Defaults to false.
// * `keepAliveDelay` in seconds to the initial delay before the first keepalive
// * `keepAliveDelay` in seconds to the initial delay before the first keepalive
// probe is sent on an idle socket. Defaults is 30 seconds.

@@ -149,13 +149,10 @@ Client.create = function(serversStr, options) {

Client.prototype.set = function(key, value, options, callback) {
var logger = this.options.logger;
var expires;
if (typeof options === 'function' || typeof callback === 'number') {
// OLD: function(key, value, callback, expires)
logger.log('MemJS SET: using deprecated call - arguments have changed');
expires = callback;
if (typeof options === 'function' && typeof callback === 'undefined') {
callback = options;
} else if (options) {
expires = options.expires;
options = {};
}
var logger = this.options.logger;
var expires = options.expires;
// TODO: support flags, support version (CAS)

@@ -196,13 +193,10 @@ this.seq++;

Client.prototype.add = function(key, value, options, callback) {
var logger = this.options.logger;
var expires;
if (typeof options === 'function') {
// OLD: function(key, value, callback, expires)
logger.log('MemJS ADD: using deprecated call - arguments have changed');
expires = callback;
if (typeof options === 'function' && typeof callback === 'undefined') {
callback = options;
} else if (options) {
expires = options.expires;
options = {};
}
var logger = this.options.logger;
var expires = options.expires;
// TODO: support flags, support version (CAS)

@@ -246,13 +240,10 @@ this.seq++;

Client.prototype.replace = function(key, value, options, callback) {
var logger = this.options.logger;
var expires;
if (typeof options === 'function') {
// OLD: function(key, value, callback, expires)
logger.log('MemJS REPLACE: using deprecated call - arguments have changed');
expires = callback;
if (typeof options === 'function' && typeof callback === 'undefined') {
callback = options;
} else if (options) {
expires = options.expires;
options = {};
}
var logger = this.options.logger;
var expires = options.expires;
// TODO: support flags, support version (CAS)

@@ -329,16 +320,11 @@ this.seq++;

Client.prototype.increment = function(key, amount, options, callback) {
var logger = this.options.logger;
var initial;
var expires;
if (typeof options === 'function') {
// OLD: function(key, amount, callback, expires, initial)
logger.log('MemJS INCREMENT: using deprecated call - arguments have changed');
initial = arguments[4];
expires = callback;
if (typeof options === 'function' && typeof callback === 'undefined') {
callback = options;
} else if (options) {
initial = options.initial;
expires = options.expires;
options = {};
}
var logger = this.options.logger;
var initial = options.initial;
var expires = options.expires;
// TODO: support version (CAS)

@@ -381,16 +367,12 @@ this.seq++;

Client.prototype.decrement = function(key, amount, options, callback) {
if (typeof options === 'function' && typeof callback === 'undefined') {
callback = options;
options = {};
}
// TODO: support version (CAS)
var logger = this.options.logger;
var initial;
var expires;
if (typeof options === 'function') {
// OLD: function(key, amount, callback, expires, initial)
logger.log('MemJS DECREMENT: using deprecated call - arguments have changed');
initial = arguments[4];
expires = callback;
callback = options;
} else if (options) {
initial = options.initial;
expires = options.expires;
}
var initial = options.initial;
var expires = options.expires;
this.seq++;

@@ -612,3 +594,3 @@ initial = initial || 0;

//
// Fetches memcache stats from each connected server. The callback is invoked
// Fetches memcache stats from each connected server. The callback is invoked
// **ONCE PER SERVER** and has the signature:

@@ -731,2 +713,1 @@ //

exports.Header = require('./header');

@@ -5,3 +5,3 @@ {

"description": "A memcache client for node using the binary protocol and SASL authentication",
"version": "0.10.2",
"version": "1.0.0-rc.1",
"homepage": "http://github.com/alevy/memjs",

@@ -28,3 +28,4 @@ "repository": {

"benchmark": "2.0.*",
"microtime": "2.1.*"}
"microtime": "2.1.*",
"docco": "*"}
}

@@ -12,3 +12,3 @@ MemJS

Documentation can be found here: [http://amitlevy.com/projects/memjs/](http://amitlevy.com/projects/memjs/)
Documentation can be found here: [https://memjs.netlify.com/](https://memjs.netlify.com/)

@@ -76,5 +76,5 @@ ## TOC

``` javascript
client.set('hello', 'world', function(err, val) {
client.set('hello', 'world', {expires:600}, function(err, val) {
}, 600);
});
```

@@ -86,7 +86,8 @@

* `val`: value to set
* `options`: an object of options. Currently supports only the key `expires`, which is a time interval, in seconds, after which memcached will expire the object
* `callback`: a callback invoked after the value is set
* `err` : error
* `val` : value retrieved
* `expiration`: time interval, in seconds, after which memcached will expire the object
### Getting Values

@@ -102,6 +103,9 @@

Note that values are always returned as `Buffer`s, regardless of whether a
`Buffer` or `String` was passed to `set`.
* `key`: key to retrieve
* `callback`: a callback invoked after the value is retrieved
* `err` : error
* `val` : value retrieved
* `val` : value retrieved as a `Buffer`

@@ -108,0 +112,0 @@ ## Contributing

@@ -67,3 +67,3 @@ var test = require('tap').test;

test('SetDeprecated', function(t) {
test('SetSuccessfulWithoutOption', function(t) {
var n = 0;

@@ -203,3 +203,3 @@ var dummyServer = new MemJS.Server();

called += 1;
if (called < 2) return;
if (called < 2) return;
t.equal(2, n, 'Ensure error is sent');

@@ -258,3 +258,3 @@ t.equal(1, callbn1, 'Ensure callback 1 is called once');

test('AddDeprecated', function(t) {
test('AddSuccessfulWithoutOption', function(t) {
var n = 0;

@@ -321,3 +321,3 @@ var dummyServer = new MemJS.Server();

test('ReplaceDeprecated', function(t) {
test('ReplaceSuccessfulWithoutOption', function(t) {
var n = 0;

@@ -486,3 +486,3 @@ var dummyServer = new MemJS.Server();

client.increment('number-increment-test', 5, {initial: 3}, function(err, success, val) {
client.increment('number-increment-test', 5, { initial: 3 }, function(err, success, val) {
callbn += 1;

@@ -499,3 +499,3 @@ t.equal(true, success);

called += 1;
if (called < 2) return;
if (called < 2) return;
t.equal(2, n, 'Ensure increment is called twice');

@@ -508,56 +508,2 @@ t.equal(2, callbn, 'Ensure callback is called twice');

test('IncrementDeprecated', function(t) {
var n = 0;
var callbn = 0;
var dummyServer = new MemJS.Server();
var expectedExtras = [
'\0\0\0\0\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0',
'\0\0\0\0\0\0\0\5\0\0\0\0\0\0\0\3\0\0\0\0'
];
dummyServer.write = function(requestBuf) {
var request = MemJS.Utils.parseMessage(requestBuf);
t.equal(5, request.header.opcode);
t.equal('number-increment-test', request.key.toString());
t.equal('', request.val.toString());
t.equal(expectedExtras[n], request.extras.toString());
n += 1;
process.nextTick(function() {
var value = new Buffer(8);
value.writeUInt32BE(request.header.opcode + 1, 4);
value.writeUInt32BE(0, 0);
dummyServer.respond({header: {status: 0, opaque: request.header.opaque}, val: value});
});
};
var client = new MemJS.Client([dummyServer]);
client.increment('number-increment-test', 5, function(err, success, val){
callbn += 1;
t.equal(true, success);
t.equal(6, val);
t.equal(null, err);
done();
});
client.increment('number-increment-test', 5, function(err, success, val) {
callbn += 1;
t.equal(true, success);
t.equal(6, val);
t.equal(null, err);
done();
}, null, 3);
var done =(function() {
var called = 0;
return function() {
called += 1;
if (called < 2) return;
t.equal(2, n, 'Ensure increment is called twice');
t.equal(2, callbn, 'Ensure callback is called twice');
t.end();
};
})();
});
test('DecrementSuccessful', function(t) {

@@ -592,3 +538,3 @@ var n = 0;

test('DecrementDeprecated', function(t) {
test('DecrementSuccessfulWithoutOption', function(t) {
var n = 0;

@@ -769,47 +715,1 @@ var dummyServer = new MemJS.Server();

return;
/*
exports.testFailoverRecovery = function(beforeExit, assert) {
Date.now = function() { return 1; }
var n1 = 0;
var n2 = 0;
var dummyServer1 = new MemJS.Server();
dummyServer1.write = function(requestBuf) {
n1 += 1;
dummyServer1.error(new Error("connection failure"));
}
var dummyServer2 = new MemJS.Server();
dummyServer2.write = function(requestBuf) {
n2 += 1;
dummyServer2.respond({header: {status: 0, opaque: request.header.opaque}});
}
var client = new MemJS.Client([dummyServer1, dummyServer2],
{failover: true});
client.get('\0', function(err, val){
assert.equal(null, err);
});
dummyServer1.write = function(requestBuf) {
n1 += 1;
dummyServer1.respond({header: {status: 0, opaque: request.header.opaque}});
}
client.get('\0', function(err, val){
assert.equal(null, err);
});
Date.now = function() {
return 60001;
}
client.get('\0', function(err, val){
assert.equal(null, err);
});
beforeExit(function() {
assert.equal(3, n1);
assert.equal(2, n2);
});
}
*/

Sorry, the diff of this file is not supported yet

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