12 lines
304 B
JavaScript
12 lines
304 B
JavaScript
// @flow
|
|
import redis from 'redis';
|
|
import redisLock from 'redis-lock';
|
|
|
|
const client = redis.createClient(process.env.REDIS_URL);
|
|
const lock = redisLock(client);
|
|
|
|
const asyncLock = (lockName: string) =>
|
|
new Promise(resolve => lock(lockName, unlock => resolve(unlock)));
|
|
|
|
export { client, asyncLock };
|