Created
September 5, 2021 12:39
-
-
Save thoughtspeed7/3da2cb4d437d60a21870e132bbf302e0 to your computer and use it in GitHub Desktop.
Connect To Redis Memorystore From Cloud Functions, Cloud Run and App Engine Using Serverless VPC Access | Google Cloud
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
// om namah shivaya | |
const { promisify } = require('util'); | |
const redis = require('redis'); | |
// replace 127.0.0.1 with your redis instance ip | |
const redisHost = '127.0.0.1'; | |
const client = redis.createClient({ | |
host: redisHost, | |
}); | |
const incrAsync = promisify(client.incr).bind(client); | |
async function main(req, res) { | |
res.send(`counter: ${await incrAsync('counter')}`); | |
} | |
module.exports = { | |
main, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment