Skip to content

Commit

Permalink
chore(redis): init client once
Browse files Browse the repository at this point in the history
Regression of 6bc7737
  • Loading branch information
jef committed Dec 26, 2020
1 parent 6bc7737 commit a908ce4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/notification/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {sendTelegramMessage} from './telegram';
import {sendTweet} from './twitter';
import {sendTwilioMessage} from './twilio';
import {sendTwitchMessage} from './twitch';
import updateRedis from './redis';
import {updateRedis} from './redis';

export function sendNotification(link: Link, store: Store) {
// Priority
Expand Down
9 changes: 4 additions & 5 deletions src/notification/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import {config} from '../config';
import {logger} from '../logger';

const {url} = config.notifications.redis;
let client: RedisClient;

function initRedis(): RedisClient | null {
if (url) {
return redis.createClient({url});
client = redis.createClient({url});
}

return null;
}

function updateRedis(link: Link, store: Store) {
export function updateRedis(link: Link, store: Store) {
try {
const client = initRedis();

if (client) {
const key = `${store.name}:${link.brand}:${link.model}`
.split(' ')
Expand All @@ -43,4 +42,4 @@ function updateRedis(link: Link, store: Store) {
}
}

export default updateRedis;
initRedis();

0 comments on commit a908ce4

Please sign in to comment.