Skip to content

Commit

Permalink
Merge pull request #31 from simocsdk/patch-1
Browse files Browse the repository at this point in the history
add redis custom db index selection
  • Loading branch information
tombeynon authored Sep 19, 2022
2 parents fdcf3c9 + adbc483 commit b8ee7c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redisClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import { createClient } from 'redis';
export async function redisClient() {
const REDIS_HOST = process.env.REDIS_HOST || 'redis';
const REDIS_PORT = process.env.REDIS_PORT || 6379;
const REDIS_DB = process.env.REDIS_DB || 0;

const client = createClient({
url: `redis://${REDIS_HOST}:${REDIS_PORT}`
});

client.on('connect', function() {
client.select(REDIS_DB); //select db index
});
client.on('error', (err) => console.log('Redis Client Error', err));

await client.connect();
return client;
}

0 comments on commit b8ee7c8

Please sign in to comment.