We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d80baa commit 3fea0d7Copy full SHA for 3fea0d7
packages/parameters/src/ExpirableValue.ts
@@ -4,10 +4,17 @@ class ExpirableValue implements ExpirableValueInterface {
4
public ttl: number;
5
public value: string | Uint8Array | Record<string, unknown>;
6
7
+ /**
8
+ * Creates a new cached value which will expire automatically
9
+ * @param value Parameter value to be cached
10
+ * @param maxAge Maximum number of seconds to cache the value for
11
+ */
12
public constructor(value: string | Uint8Array | Record<string, unknown>, maxAge: number) {
13
this.value = value;
- const timeNow = new Date();
- this.ttl = timeNow.setSeconds(timeNow.getSeconds() + maxAge);
14
+
15
+ const maxAgeInMilliseconds = maxAge * 1000;
16
+ const nowTimestamp = Date.now();
17
+ this.ttl = nowTimestamp + maxAgeInMilliseconds;
18
}
19
20
public isExpired(): boolean {
0 commit comments