Spaces:
Sleeping
Sleeping
Update src/server.ts
Browse files- src/server.ts +5 -3
src/server.ts
CHANGED
|
@@ -31,10 +31,12 @@ class IdempotencyCache {
|
|
| 31 |
constructor(maxSize = 2000) { this.maxSize = maxSize; }
|
| 32 |
has(uuid: string) { return this.map.has(uuid); }
|
| 33 |
add(uuid: string) {
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
this.map.delete(firstKey);
|
|
|
|
| 38 |
}
|
| 39 |
}
|
| 40 |
}
|
|
|
|
| 31 |
constructor(maxSize = 2000) { this.maxSize = maxSize; }
|
| 32 |
has(uuid: string) { return this.map.has(uuid); }
|
| 33 |
add(uuid: string) {
|
| 34 |
+
this.map.set(uuid, true);
|
| 35 |
+
if (this.map.size > this.maxSize) {
|
| 36 |
+
const firstKey = this.map.keys().next().value as string | undefined;
|
| 37 |
+
if (firstKey !== undefined) {
|
| 38 |
this.map.delete(firstKey);
|
| 39 |
+
}
|
| 40 |
}
|
| 41 |
}
|
| 42 |
}
|