-
-
Save stockholmux/b225524ddd03ae50b4089a8f509ce1a2 to your computer and use it in GitHub Desktop.
node_redis_connection
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
let | |
redis = require('redis'), | |
/* Values are hard-coded for this example, it's usually best to bring these in via file or environment variable for production */ | |
client = redis.createClient({ | |
port : 6379, // replace with your port | |
host : '120.0.0.1', // replace with your hostanme or IP address | |
password : 'your password', // replace with your password | |
// optional, if using SSL | |
// use `fs.readFile[Sync]` or another method to bring these values in | |
tls : { | |
key : stringValueOfKeyFile, | |
cert : stringValueOfCertFile, | |
ca : [ stringValueOfCaCertFile ] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK. This is pretty straight forward (if I understand your intended use). You could create a class to do this but honestly, I don't know what you'd gain. Here are the things you need to know:
client.get
to your requested key. In Express, you can do this either in callback directly (app.post('/whatever/', (req,res) => { client.get( .... ) })
) or implement this as a middleware which would be cleaner.