Skip to content

Instantly share code, notes, and snippets.

@tomfa
Created August 23, 2022 18:00
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 tomfa/1dc90f12901e7a8e4a9c5c2fb336df49 to your computer and use it in GitHub Desktop.
Save tomfa/1dc90f12901e7a8e4a9c5c2fb336df49 to your computer and use it in GitHub Desktop.
Connecting to AWS Elasticache (with ioredis + Bull)
import Redis from 'ioredis';
const requiresTLS = process.env.NODE_ENV === 'production';
const client = new Redis({
host: process.env.REDIS_HOST as string,
password: process.env.REDIS_PASSWORD as string,
port: parseInt(process.env.REDIS_PORT, 10),
// {} prop enables TLS (typical for production, not while developing locally)
tls: requiresTLS ? {} : undefined,
/* Uncomment lines below if using bull
Using a redis instance with enableReadyCheck or maxRetriesPerRequest
for bclient/subscriber is not permitted.
see https://github.com/OptimalBits/bull/issues/1873
*/
// maxRetriesPerRequest: null,
// enableReadyCheck: false
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment