Skip to content

Instantly share code, notes, and snippets.

@miladr0
Last active October 17, 2020 17:27
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 miladr0/7de3d8df19de66f3c5101b001c40e4e8 to your computer and use it in GitHub Desktop.
Save miladr0/7de3d8df19de66f3c5101b001c40e4e8 to your computer and use it in GitHub Desktop.
import Redis from 'ioredis';
const PORT = process.env.REDIS_PORT;
const HOST = process.env.REDIS_HOST;
const client = new Redis(PORT, HOST);
const subscriber = new Redis(PORT, HOST);
const opts = {
createClient(type) {
switch (type) {
case 'client':
return client;
case 'subscriber':
return subscriber;
default:
return new Redis(PORT, HOST);
}
},
};
export default opts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment