Skip to content

Commit 64397bb

Browse files
committed
feat: add random delay
1 parent 2a6a63d commit 64397bb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/core/card.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class Generator {
1515
};
1616
public cache: Cache;
1717
public headers: Record<string, string>;
18+
public count = 0;
1819

1920
constructor(cache: Cache, headers?: Record<string, string>) {
2021
this.cache = cache;
@@ -54,7 +55,9 @@ export class Generator {
5455
): Promise<FetchedData> {
5556
this.log("fetching", username, site);
5657
const cache_key = `data-${username.toLowerCase()}-${site}`;
58+
console.log("cache_key", cache_key);
5759

60+
await new Promise((resolve) => setTimeout(resolve, 200 * (this.count++ % 5)));
5861
const cached: FetchedData | null = await this.cache.get(cache_key);
5962
if (cached) {
6063
this.log("fetch cache hit");

0 commit comments

Comments
 (0)