diff --git a/package.json b/package.json index 9018a9e..f76baaf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "memcached" , "version": "0.0.1" , "author": "Arnout Kazemier" -, "description": "A fully featured Memcached client, supporting both single and clustered Memcached server through consistent hashing and failover/ failure" +, "description": "A fully featured Memcached API client, supporting both single and clustered Memcached servers through consistent hashing and failover/failure" , "main": "index" , "keywords":[ "memcached" @@ -15,6 +15,7 @@ , "cache" , "nosql" , "membase" + , "InnoDB memcached API" ] , "directories": { "lib": "./lib" diff --git a/tests/memcached-cas.test.js b/tests/memcached-cas.test.js index 705bbec..e8bfe3a 100644 --- a/tests/memcached-cas.test.js +++ b/tests/memcached-cas.test.js @@ -42,7 +42,7 @@ module.exports = { } /** - * Create a sucessful cas update + * Create a successful cas update, so we are sure we send a cas request correctly */ , "successful cas update" : function(){ var memcached = new Memcached(common.servers.single) @@ -61,6 +61,7 @@ module.exports = { message = common.alphabet(256); memcached.cas("test:" + testnr, message, answer.cas, 1000, function(error, answer){ assert.ok(!error); + assert.ok(!!answer); memcached.get("test:" + testnr, function(error, answer){ @@ -73,4 +74,41 @@ module.exports = { }); }); } + +/** + * Create a successful cas update, so we are sure we send a cas request correctly + */ +, "unsuccessful cas update" : function(){ + var memcached = new Memcached(common.servers.single) + , message = common.alphabet(256) + , testnr = ++global.testnumbers; + + memcached.set("test:" + testnr, message, 1000, function(error, ok){ + assert.ok(!error); + ok.should.be.true; + + memcached.gets("test:" + testnr, function(error, answer){ + assert.ok(!error); + assert.ok(!!answer.cas); + + // generate new message + message = common.alphabet(256); + memcached.set("test:" + testnr, message, 1000, function(){ + memcached.cas("test:" + testnr, message, answer.cas, 1000, function(error, answer){ + assert.ok(!error); + assert.ok(!answer); + + memcached.get("test:" + testnr, function(error, answer){ + + assert.ok(!error); + answer.should.eql(message); + + memcached.end(); // close connections + }) + }); + }); + }); + }); + } + }; \ No newline at end of file diff --git a/tests/memcached-get-set.test.js b/tests/memcached-get-set.test.js index f3a7fc5..2585f3b 100644 --- a/tests/memcached-get-set.test.js +++ b/tests/memcached-get-set.test.js @@ -19,8 +19,8 @@ module.exports = { /** * Make sure that the string that we send to the server is correctly - * stored and retreived. We will be storing random strings to ensure - * that we are not retreiving old data. + * stored and retrieved. We will be storing random strings to ensure + * that we are not retrieving old data. */ "set and get a regular string": function(){ var memcached = new Memcached(common.servers.single) @@ -68,7 +68,7 @@ module.exports = { /** * Make sure that Numbers are correctly send and stored on the server - * retreival of the number based values can be tricky as the client might + * retrieval of the number based values can be tricky as the client might * think that it was a INCR and not a SET operation.. So just to make sure.. */ , "set and get a regular number": function(){ @@ -93,7 +93,7 @@ module.exports = { /** * Objects should be converted to a JSON string, send to the server - * and be automagically JSON.parsed when they are retreived. + * and be automagically JSON.parsed when they are retrieved. */ , "set and get a object": function(){ var memcached = new Memcached(common.servers.single) @@ -121,7 +121,7 @@ module.exports = { /** * Arrays should be converted to a JSON string, send to the server - * and be automagically JSON.parsed when they are retreived. + * and be automagically JSON.parsed when they are retrieved. */ , "set and get a array": function(){ var memcached = new Memcached(common.servers.single) @@ -156,10 +156,13 @@ module.exports = { } /** - * Bufers are commonly used for binary transports So we need to make sure - * we support them propperly + * Buffers are commonly used for binary transports So we need to make sure + * we support them properly. But please note, that we need to compare the + * strings on a "binary" level, because that is the encoding the Memcached + * client will be using, as there is no indication of what encoding the + * buffer is in. */ -, "set and get buffers": function(){ +, "set and get with a binary image": function(){ var memcached = new Memcached(common.servers.single) , message = fs.readFileSync(__dirname + '/fixtures/hotchicks.jpg') , testnr = ++global.testnumbers; @@ -177,7 +180,33 @@ module.exports = { } /** - * Not only small strings, but also large strings should be procesed + * Get binary of the lipsum.txt, send it over the connection and see + * if after we retrieved it, it's still the same when we compare the + * original with the memcached based version. + * + * A use case for this would be storing with HTML data in + * memcached as a single cache pool.. + */ +, "set and get with a binary text file": function(){ + var memcached = new Memcached(common.servers.single) + , message = fs.readFileSync(__dirname + '/fixtures/lipsum.txt') + , testnr = ++global.testnumbers; + + memcached.set("test:" + testnr, message, 1000, function(error, ok){ + assert.ok(!error); + ok.should.be.true; + + memcached.get("test:" + testnr, function(error, answer){ + assert.ok(!error); + assert.ok(answer.toString('utf8') === answer.toString('utf8')); + assert.ok(answer.toString('ascii') === answer.toString('ascii')); + memcached.end(); // close connections + }); + }); + } + +/** + * Not only small strings, but also large strings should be processed * without any issues. */ , "set and get large text files": function(){ @@ -202,7 +231,7 @@ module.exports = { /** * A multi get on a single server is different than a multi server multi get * as a multi server multi get will need to do a multi get over multiple servers - * yes, that's allot of multi's in one single sentance thanks for noticing + * yes, that's allot of multi's in one single sentence thanks for noticing */ , "multi get single server": function(){ var memcached = new Memcached(common.servers.single) @@ -233,7 +262,7 @@ module.exports = { /** * A multi get on a single server is different than a multi server multi get * as a multi server multi get will need to do a multi get over multiple servers - * yes, that's allot of multi's in one single sentance thanks for noticing + * yes, that's allot of multi's in one single sentence thanks for noticing */ , "multi get multi server": function(){ var memcached = new Memcached(common.servers.multi)