perf: Reuse redis connections where possible (#1157)

* reuse redis connections where possible

* redis -> ioredis
This commit is contained in:
Tom Moor
2020-01-13 18:17:41 -08:00
committed by GitHub
parent f231c664e6
commit 5b78cb8963
8 changed files with 41 additions and 19 deletions

19
server/utils/queue.js Normal file
View File

@ -0,0 +1,19 @@
// @flow
import Redis from 'ioredis';
import Queue from 'bull';
import { client, subscriber } from '../redis';
export function createQueue(name: string) {
return new Queue(name, {
createClient(type) {
switch (type) {
case 'client':
return client;
case 'subscriber':
return subscriber;
default:
return new Redis(process.env.REDIS_URL);
}
},
});
}