* wip * wip working group queue * wip * wip * wip * fix: groupmq package (tests failed) * minor fixes * fix: zero is fine for duration * add logger * fix: make buffers more lightweight * bump groupmq * new buffers and bump groupmq * fix: buffers based on comments * fix: use profileId as groupId if exists * bump groupmq * add concurrency env for only events
21 lines
392 B
TypeScript
21 lines
392 B
TypeScript
import { getRedisCache } from './redis';
|
|
|
|
export async function runEvery({
|
|
interval,
|
|
fn,
|
|
key,
|
|
}: {
|
|
interval: number;
|
|
fn: () => Promise<void> | void;
|
|
key: string;
|
|
}) {
|
|
const cacheKey = `run-every:${key}`;
|
|
const cacheExists = await getRedisCache().get(cacheKey);
|
|
if (cacheExists) {
|
|
return;
|
|
}
|
|
|
|
await getRedisCache().set(cacheKey, '1', 'EX', interval);
|
|
return fn();
|
|
}
|