From 17045678edd219a2d572e5ce572c2c8ebeebb562 Mon Sep 17 00:00:00 2001 From: Bryan Goldstein Date: Thu, 5 Sep 2019 23:48:52 -0400 Subject: [PATCH 1/4] attempt to demonstrate RDB failure * would be nice to have an easy example of disabling persistence * nicer to have a sane default of disabled --- redis/client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redis/client.js b/redis/client.js index 8705238..d50f2ce 100644 --- a/redis/client.js +++ b/redis/client.js @@ -10,6 +10,9 @@ redisClient.on("error", function(err) { redisClient.set("string key", "string val", redis.print); redisClient.hset("hash key", "hashtest 1", "some value", redis.print); redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print); +Array.from({length: 10000}).forEach(function() { + redisClient.set("key: " + i, "val: " + i, redis.print); +}); redisClient.hkeys("hash key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { From fdeb74df39fd940deaae79364ff5362492593ddf Mon Sep 17 00:00:00 2001 From: Bryan Goldstein Date: Thu, 5 Sep 2019 23:50:57 -0400 Subject: [PATCH 2/4] Update client.js --- redis/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/client.js b/redis/client.js index d50f2ce..55e5a4d 100644 --- a/redis/client.js +++ b/redis/client.js @@ -10,7 +10,7 @@ redisClient.on("error", function(err) { redisClient.set("string key", "string val", redis.print); redisClient.hset("hash key", "hashtest 1", "some value", redis.print); redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print); -Array.from({length: 10000}).forEach(function() { +Array.from({length: 10000}).forEach(function(i) { redisClient.set("key: " + i, "val: " + i, redis.print); }); redisClient.hkeys("hash key", function (err, replies) { From 42272d7a95b6dcdfe9113294863624985dfd9c4b Mon Sep 17 00:00:00 2001 From: Bryan Goldstein Date: Fri, 6 Sep 2019 00:00:54 -0400 Subject: [PATCH 3/4] try and qualify for rdb snapshot --- redis/client.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/redis/client.js b/redis/client.js index 55e5a4d..0480593 100644 --- a/redis/client.js +++ b/redis/client.js @@ -10,9 +10,15 @@ redisClient.on("error", function(err) { redisClient.set("string key", "string val", redis.print); redisClient.hset("hash key", "hashtest 1", "some value", redis.print); redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print); + Array.from({length: 10000}).forEach(function(i) { redisClient.set("key: " + i, "val: " + i, redis.print); }); +setTimeout(function() { + Array.from({length: 10000}).forEach(function(i) { + redisClient.set("key: " + i, "val: " + i, redis.print); + }); +}, 120000); redisClient.hkeys("hash key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { From ac32cebee5f128a7d79f642e414eb9907e64f362 Mon Sep 17 00:00:00 2001 From: Bryan Goldstein Date: Fri, 6 Sep 2019 00:05:02 -0400 Subject: [PATCH 4/4] Update client.js --- redis/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redis/client.js b/redis/client.js index 0480593..6117d18 100644 --- a/redis/client.js +++ b/redis/client.js @@ -4,7 +4,7 @@ const redis = require("redis"); redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST); redisClient.on("error", function(err) { - console.log("Error " + err); + throw new Error("Error " + err); }); redisClient.set("string key", "string val", redis.print); @@ -17,6 +17,7 @@ Array.from({length: 10000}).forEach(function(i) { setTimeout(function() { Array.from({length: 10000}).forEach(function(i) { redisClient.set("key: " + i, "val: " + i, redis.print); + redisClient.quit(); }); }, 120000); redisClient.hkeys("hash key", function (err, replies) { @@ -24,5 +25,4 @@ redisClient.hkeys("hash key", function (err, replies) { replies.forEach(function (reply, i) { console.log(" " + i + ": " + reply); }); - redisClient.quit(); });