1 | // Retrieve the expiration date when caching a file
|
2 | const getExpires = function(ttl) {
|
3 | if (!Number.isInteger(ttl) || ttl < 1) {
|
4 | return
|
5 | }
|
6 |
|
7 | return Date.now() + ttl * SECS_TO_MSECS
|
8 | }
|
9 |
|
10 | const SECS_TO_MSECS = 1e3
|
11 |
|
12 | // Check if a file about to be restored is expired
|
13 | const checkExpires = function(expires) {
|
14 | return expires !== undefined && Date.now() > expires
|
15 | }
|
16 |
|
17 | module.exports = { getExpires, checkExpires }
|