mm_cachebase 1.8.8 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -494,7 +494,7 @@ CacheBase.prototype.expire = function(key, seconds) {
|
|
|
494
494
|
return false;
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
-
if (
|
|
497
|
+
if (typeof seconds !== 'number' || seconds <= 0) {
|
|
498
498
|
return false;
|
|
499
499
|
}
|
|
500
500
|
|
|
@@ -1582,7 +1582,7 @@ CacheBase.prototype.ttl = function(key, seconds) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
|
|
1584
1584
|
// 判断是否为设置过期时间模式
|
|
1585
|
-
if (arguments.length > 1) {
|
|
1585
|
+
if (arguments.length > 1 && seconds !== undefined) {
|
|
1586
1586
|
// 设置过期时间模式
|
|
1587
1587
|
if (typeof seconds !== 'number' || seconds < 0) {
|
|
1588
1588
|
return false;
|
|
@@ -1633,12 +1633,12 @@ CacheBase.prototype.ttl = function(key, seconds) {
|
|
|
1633
1633
|
return Math.max(0, Math.ceil(remaining / 1000));
|
|
1634
1634
|
}
|
|
1635
1635
|
} catch (error) {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1636
|
+
const errorMsg = arguments.length > 1 && seconds !== undefined
|
|
1637
|
+
? `Failed to set ttl for key ${key}: ${error.message}`
|
|
1638
|
+
: `Failed to get ttl for key ${key}: ${error.message}`;
|
|
1639
|
+
this.emit('error', new Error(errorMsg));
|
|
1640
|
+
return arguments.length > 1 && seconds !== undefined ? false : -2;
|
|
1641
|
+
}
|
|
1642
1642
|
};
|
|
1643
1643
|
|
|
1644
1644
|
/**
|