Last active
September 18, 2019 14:44
-
-
Save kristoff-it/02184cb8a37c470409a97e1560ead37f to your computer and use it in GitHub Desktop.
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
// Connection info, a URI with this shape: | |
// [redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]] | |
const REDIS_URI = process.env.REDIS_URI; | |
// Redis client library | |
const redis = require('redis'); | |
// Client instance | |
const r = redis.createClient(REDIS_URI); | |
// Promisify get and set | |
const { promisify } = require('util'); | |
const setAsync = promisify(r.set).bind(r); | |
const getAsync = promisify(r.get).bind(r); | |
// This is the lambda function: | |
exports.handler = async function(event, context) { | |
console.log("EVENT: \n" + JSON.stringify(event, null, 2)) | |
// Set a key | |
await setAsync("mykey", "hello world"); | |
// Return the value to the caller | |
return getAsync("mykey"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment