Skip to content

Instantly share code, notes, and snippets.

@feliperohdee
Created May 30, 2018 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feliperohdee/8ecde1c109bd3787d91028e011351861 to your computer and use it in GitHub Desktop.
Save feliperohdee/8ecde1c109bd3787d91028e011351861 to your computer and use it in GitHub Desktop.
AWS Lambda: Reusing database connections
const Redis = require('ioredis');
const redis = new Redis();
exports.handler = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
redis.pipeline()
.set('a', 'b')
.get('a')
.exec()
.then(response => callback(null, response))
.catch(err => callback(err));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment