Skip to content

Commit 2eb7069

Browse files
committed
2 parents c362fdc + 4abc93e commit 2eb7069

4 files changed

Lines changed: 37 additions & 37 deletions

File tree

example.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function microtime(get_as_float) {
88
}
99

1010
var onConnect = function() {
11-
mcClient.get('test', function(data) {
11+
mcClient.get('test', function(err, data) {
1212
sys.debug(data);
1313
mcClient.close();
1414
});
@@ -20,8 +20,8 @@ var benchmark = function() {
2020
var x = 0;
2121

2222
for (var i=0; i<=count; i++) {
23-
mcClient.get('test', function(data) {
24-
x += 1;
23+
mcClient.get('test', function(err, data) {
24+
x += 1;
2525
if (x == count) {
2626
end = microtime(true);
2727
sys.debug('total time: ' + (end - start));
@@ -33,30 +33,30 @@ var benchmark = function() {
3333
};
3434

3535
var setKey = function() {
36-
mcClient.set('test', 'hello \r\n node-memcache', function(response) {
37-
mcClient.get('test', function(data) {
36+
mcClient.set('test', 'hello \r\n node-memcache', function(err, response) {
37+
mcClient.get('test', function(err, data) {
3838
sys.debug(data);
3939
mcClient.close();
4040
});
4141
});
4242
};
4343

4444
var version = function() {
45-
mcClient.version(function(version) {
45+
mcClient.version(function(err, version) {
4646
sys.debug(version);
4747
mcClient.close();
4848
});
4949
};
5050

5151
var incr = function() {
52-
mcClient.increment('x', 2, function(new_value) {
52+
mcClient.increment('x', 2, function(err, new_value) {
5353
sys.debug(new_value);
5454
mcClient.close();
5555
});
5656
};
5757

5858
var decr = function() {
59-
mcClient.decrement('x', 1, function(new_value) {
59+
mcClient.decrement('x', 1, function(err, new_value) {
6060
sys.debug(new_value);
6161
mcClient.close();
6262
});

lib/memcache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Client.prototype.handle_received_data = function(){
235235
var callback = this.callbacks.shift();
236236
if (callback != null && callback.fun){
237237
this.replies++;
238-
callback.fun(result_value, result_error);
238+
callback.fun(result_error, result_value);
239239
}
240240
}
241241
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"repository": "git://github.com/elbart/node-memcache.git",
77
"author": "Tim Eggert <tim@elbart.com>",
88
"main": "./lib/memcache",
9-
"dependencies": {
9+
"devDependencies": {
1010
"expresso": ">=0.7.0"
1111
},
1212
"directories": {

test/test-memcache.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mc.addHandler(function() {
3030
// test nonexistent key is null
3131
exports['test null value'] = function(beforeExit) {
3232
var n = 0;
33-
mc.get('no such key', function(r) {
33+
mc.get('no such key', function(err, r) {
3434
assert.equal(null, r);
3535
n++;
3636
});
@@ -46,7 +46,7 @@ mc.addHandler(function() {
4646
// set key
4747
mc.set('set1', 'asdf1', function() {
4848
n++;
49-
mc.get('set1', function(r) {
49+
mc.get('set1', function(err, r) {
5050
// assert key is found
5151
assert.equal('asdf1', r);
5252
n++;
@@ -68,7 +68,7 @@ mc.addHandler(function() {
6868

6969
exports['test set get with integer value'] = function(beforeExit) {
7070
mc.set('testKey', 123, function() {
71-
mc.get('testKey', function(r) {
71+
mc.get('testKey', function(err, r) {
7272
assert.equal(123,r);
7373
});
7474
});
@@ -80,13 +80,13 @@ mc.addHandler(function() {
8080
// set key
8181
mc.set('set2', 'asdf2', function() {
8282
n++;
83-
mc.get('set2', function(r) {
83+
mc.get('set2', function(err, r) {
8484
// assert key is found
8585
assert.equal('asdf2', r);
8686
n++;
8787
// delete key
8888
mc.delete('set2', function() {
89-
mc.get('set2', function(r) {
89+
mc.get('set2', function(err, r) {
9090
// assert key is null
9191
assert.equal(null, r);
9292
n++;
@@ -103,7 +103,7 @@ mc.addHandler(function() {
103103
// test utf8 handling
104104
exports['utf8'] = function(beforeExit) {
105105
mc.set('key1', 'привет', function() {
106-
mc.get('key1', function(r) {
106+
mc.get('key1', function(err, r) {
107107
assert.equal('привет', r);
108108
});
109109
});
@@ -136,44 +136,44 @@ mc.addHandler(function() {
136136

137137
var n = 0;
138138

139-
mc.set('inc_bad', 'HELLO', function(response){
139+
mc.set('inc_bad', 'HELLO', function(err, response){
140140
assert.equal(response, 'STORED');
141141
n++;
142-
mc.increment('inc_bad', 2, function(ok, err){
142+
mc.increment('inc_bad', 2, function(err, ok){
143143
n++;
144-
assert.equal(ok, null);
145144
assert.match(err, /^CLIENT_ERROR/);
145+
assert.equal(ok, null);
146146
});
147-
mc.decrement('inc_bad', 3, function(ok, err){
147+
mc.decrement('inc_bad', 3, function(err, ok){
148148
n++;
149-
assert.equal(ok, null);
150149
assert.match(err, /^CLIENT_ERROR/);
150+
assert.equal(ok, null);
151151
});
152-
mc.increment('inc_bad', null, function(ok, err){
152+
mc.increment('inc_bad', null, function(err, ok){
153153
n++;
154-
assert.equal(ok, null);
155154
assert.match(err, /^CLIENT_ERROR/);
155+
assert.equal(ok, null);
156156
});
157-
mc.decrement('inc_bad', null, function(ok, err){
157+
mc.decrement('inc_bad', null, function(err, ok){
158158
n++;
159-
assert.equal(ok, null);
160159
assert.match(err, /^CLIENT_ERROR/);
160+
assert.equal(ok, null);
161161
});
162162
});
163163

164-
mc.set('inc_good', '5', function(response){
164+
mc.set('inc_good', '5', function(err, response){
165165
assert.equal(response, 'STORED');
166166
n++;
167-
mc.increment('inc_good', 2, function(response){
167+
mc.increment('inc_good', 2, function(err, response){
168168
n++;
169169
assert.equal(response, 7);
170-
mc.increment('inc_good', function(response){
170+
mc.increment('inc_good', function(err, response){
171171
n++;
172172
assert.equal(response, 8);
173-
mc.decrement('inc_good', function(response){
173+
mc.decrement('inc_good', function(err, response){
174174
n++;
175175
assert.equal(response, 7);
176-
mc.decrement('inc_good', 4, function(response){
176+
mc.decrement('inc_good', 4, function(err, response){
177177
n++;
178178
assert.equal(response, 3);
179179
});
@@ -191,7 +191,7 @@ mc.addHandler(function() {
191191
exports['version'] = function(beforeExit){
192192
var n = 0;
193193

194-
mc.version(function(success, error){
194+
mc.version(function(error, success){
195195
n++;
196196
assert.equal(error, null);
197197
assert.length(success, 5);
@@ -205,21 +205,21 @@ mc.addHandler(function() {
205205
exports['stats'] = function(beforeExit){
206206
var n = 0;
207207

208-
mc.stats(function(success, error){
208+
mc.stats(function(error, success){
209209
n++;
210210
assert.ok(success.pid, "server has a pid");
211211
});
212212

213-
mc.stats('settings', function(success, error){
213+
mc.stats('settings', function(error, success){
214214
n++;
215215
assert.ok(success.maxconns);
216216
});
217217

218-
mc.stats('items', function(success, error){ n++; assert.ok(num_keys(success)); });
219-
mc.stats('sizes', function(success, error){ n++; assert.ok(num_keys(success)); });
220-
mc.stats('slabs', function(success, error){ n++; assert.ok(num_keys(success)); });
218+
mc.stats('items', function(error, success){ n++; assert.ok(num_keys(success)); });
219+
mc.stats('sizes', function(error, success){ n++; assert.ok(num_keys(success)); });
220+
mc.stats('slabs', function(error, success){ n++; assert.ok(num_keys(success)); });
221221

222-
mc.stats('notreal', function(success, error){
222+
mc.stats('notreal', function(error, success){
223223
n++;
224224
assert.equal(error, 'ERROR');
225225
});

0 commit comments

Comments
 (0)