-
-
Save vekexasia/cb6563d10389cb9a5754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require('redis'); | |
/* ENvironment variables */ | |
/* | |
/**/ | |
var dbhost = process.env.DBHOST; | |
var dbport = process.env.DBPORT; | |
var dbpass = process.env.DBPASSWORD; | |
/**/ | |
/* / end environment variables */ | |
var redisClient = redis.createClient(dbport, dbhost); | |
if (typeof(dbpass) !== 'undefined') { | |
redisClient.auth(dbpass, function (err, data) { | |
redisClient.select('0',function(err, data) { | |
doTest(); | |
}); | |
}); | |
} else { | |
doTest(); | |
} | |
function doTest() { | |
var bit = []; | |
for (i=0;i<300;i++) { | |
bit.push(i); | |
} | |
var multi = redisClient.multi(); | |
multi.incr('test'); | |
multi.sadd('user:fb:test:friends', bit); | |
multi.exec(function(err, replies) { | |
// Should check this works. | |
// console.log(err); // null | |
// console.log(replies); // [1, 300] or [n, 0] --- depending on the number of times you launch this | |
redisClient.smembers('user:fb:test:friends', function(err, data) { | |
if (data[data.length-1] === null) { | |
console.error("KO"); | |
} else { | |
console.log("OK"); | |
} | |
//console.log("Length: "+data.length); // output 300 | |
redisClient.end(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment