Skip to content

Instantly share code, notes, and snippets.

@Streek
Created January 2, 2019 22:02
Show Gist options
  • Select an option

  • Save Streek/7fbe99898f6cf30f866a759411f8af96 to your computer and use it in GitHub Desktop.

Select an option

Save Streek/7fbe99898f6cf30f866a759411f8af96 to your computer and use it in GitHub Desktop.
check if key exists, react if it does.
var redis = require("redis"),
client = redis.createClient();
const object = {/*full json of thing...*/ };
client.on("error", function (err) {
console.log("Error " + err);
});
const redisKeyCreateOrContinue(object) {
const uniqId = MD5(JSON.stringify(object));
client.get(uniqId, (err, reply) => {
if (reply || err) {
// DO NOT ADD TO QUEUE WE ALREADY HAVE DONE THIS OBJECT
} else {
// ADD TO QUEUE AND ADD TO SET
client.set(uniqId, object, (response) => {
console.log("res:", response);
});
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment