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.
Files changed (2) hide show
  1. package/index.js +8 -8
  2. 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 (!Number.isInteger(seconds) || seconds <= 0) {
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
- const errorMsg = arguments.length > 1
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 ? false : -2;
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_cachebase",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
4
4
  "description": "一个轻量级的本地缓存类库,提供与Redis兼容的API接口,支持过期时间设置、哈希表操作、数值操作、字符串操作等功能,以及完整的事件通知系统和多文件持久化功能。",
5
5
  "main": "index.js",
6
6
  "scripts": {