MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / runEvery

Function runEvery

packages/redis/run-every.ts:3–20  ·  view source on GitHub ↗
({
  interval,
  fn,
  key,
}: {
  interval: number;
  fn: () => Promise<void> | void;
  key: string;
})

Source from the content-addressed store, hash-verified

1import { getRedisCache } from './redis';
2
3export async function runEvery({
4 interval,
5 fn,
6 key,
7}: {
8 interval: number;
9 fn: () => Promise<void> | void;
10 key: string;
11}) {
12 const cacheKey = `run-every:${key}`;
13 const cacheExists = await getRedisCache().get(cacheKey);
14 if (cacheExists) {
15 return;
16 }
17
18 await getRedisCache().set(cacheKey, '1', 'EX', interval);
19 return fn();
20}

Callers

nothing calls this directly

Calls 4

getRedisCacheFunction · 0.90
fnFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected