Browse Source
fix: Set cache overflow of the setTimeout Maximum delay value (#1742)
pull/1755/head
chenls
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
src/utils/cache/memory.ts
|
|
|
@ -58,7 +58,12 @@ export class Memory<T = any, V = any> { |
|
|
|
return value; |
|
|
|
} |
|
|
|
const now = new Date().getTime(); |
|
|
|
item.time = now + expires; |
|
|
|
/** |
|
|
|
* Prevent overflow of the setTimeout Maximum delay value |
|
|
|
* Maximum delay value 2,147,483,647 ms |
|
|
|
* https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value
|
|
|
|
*/ |
|
|
|
item.time = expires > now ? expires : now + expires; |
|
|
|
item.timeoutId = setTimeout( |
|
|
|
() => { |
|
|
|
this.remove(key); |
|
|
|
|