mm_cachebase 2.0.5 → 2.0.6

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.
@@ -0,0 +1 @@
1
+ {data:{},expires:{},types:{},timestamp:1793313151555}
@@ -0,0 +1 @@
1
+ {data:{},expires:{},types:{},timestamp:1793313151543}
package/index.js CHANGED
@@ -17,7 +17,7 @@ function cachebaseAdmin(scope, config) {
17
17
  if (!scope) {
18
18
  scope = 'os';
19
19
  }
20
- return admin.get(scope, { name: scope, ...config });
20
+ return admin.get(scope, config);
21
21
  }
22
22
 
23
23
  // 导出类
package/lib/cachebase.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @class CacheBase
5
5
  * @extends Base
6
6
  */
7
- const Base = require('mm_corejs').Base;
7
+ const Base = require('mm_mod').Base;
8
8
  const { fullname, hasFile, loadJson, saveJson, addDir } = require('mm_helper');
9
9
 
10
10
  class CacheBase extends Base {
@@ -129,10 +129,13 @@ CacheBase.prototype._initService = async function () {
129
129
  try {
130
130
  // 设置文件路径
131
131
  this._setFilePath();
132
- // 初始化过期检查定时器
132
+ // 初始化过期检查定时器(unref,避免后台清理任务阻止宿主进程退出)
133
133
  this._check_timer = setInterval(() => {
134
134
  this.clearExpire();
135
135
  }, this.config.expire_check_interval || 1000);
136
+ if (typeof this._check_timer.unref === 'function') {
137
+ this._check_timer.unref();
138
+ }
136
139
 
137
140
  // 设置最大大小限制
138
141
  if (this.config.max_size) {
@@ -162,6 +165,10 @@ CacheBase.prototype._connect = function () {
162
165
  this._save_timer = setInterval(() => {
163
166
  this.save();
164
167
  }, this.config.save_interval || 30000);
168
+ // unref,避免后台保存定时器阻止宿主进程退出
169
+ if (typeof this._save_timer.unref === 'function') {
170
+ this._save_timer.unref();
171
+ }
165
172
  }
166
173
  };
167
174
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_cachebase",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "一个轻量级的本地缓存类库,接口与 mm_redis 完全对齐:全异步API、冒号风格事件、统一签名与返回值,支持字符串、哈希、列表、集合、有序集合、发布订阅。",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "persist",
36
36
  "scope"
37
37
  ],
38
- "layer": "port",
38
+ "layer": "adapter",
39
39
  "group": "cache",
40
40
  "author": "邱文武",
41
41
  "license": "MIT",
@@ -45,6 +45,10 @@
45
45
  "homepage": "https://gitee.com/qiuwenwu91/mm_cachebase#readme",
46
46
  "dependencies": {
47
47
  "mm_corejs": "^1.1.5",
48
+ "mm_mod": "^1.0.1",
48
49
  "mm_helper": "^1.0.1"
50
+ },
51
+ "devDependencies": {
52
+ "mm_eslint": "^1.7.7"
49
53
  }
50
54
  }