Created
January 2, 2019 22:02
-
-
Save Streek/7fbe99898f6cf30f866a759411f8af96 to your computer and use it in GitHub Desktop.
check if key exists, react if it does.
This file contains hidden or 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"), | |
| 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