Skip to content

Instantly share code, notes, and snippets.

Last active Sep 18, 2019
What would you like to do?
// 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