mm_cachebase 1.9.5 → 1.9.7
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 +0 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -80,7 +80,6 @@ CacheBase.prototype.init = async function () {
|
|
|
80
80
|
try {
|
|
81
81
|
await this._initService();
|
|
82
82
|
this.is_inited = true;
|
|
83
|
-
this.log('info', 'CacheBase service initialized successfully');
|
|
84
83
|
} catch (error) {
|
|
85
84
|
this.log('error', 'Failed to initialize CacheBase service:', error);
|
|
86
85
|
}
|
|
@@ -96,7 +95,6 @@ CacheBase.prototype._loadExternalConfig = function () {
|
|
|
96
95
|
const config_path = './config/cachebase.config.json'.fullname(__dirname);
|
|
97
96
|
if (config_path.hasFile()) {
|
|
98
97
|
const config = config_path.loadJson();
|
|
99
|
-
this.log('info', '外部配置文件加载成功');
|
|
100
98
|
return config;
|
|
101
99
|
}
|
|
102
100
|
} catch (error) {
|
|
@@ -113,7 +111,6 @@ CacheBase.prototype._setFilePath = function () {
|
|
|
113
111
|
const scope = this.config.scope || 'sys';
|
|
114
112
|
const dir = this.config.dir || './cache';
|
|
115
113
|
this.file_path = `./${scope}.json`.fullname(dir);
|
|
116
|
-
this.log('info', `文件路径设置为: ${this.file_path}`);
|
|
117
114
|
};
|
|
118
115
|
|
|
119
116
|
/**
|
|
@@ -168,17 +165,11 @@ CacheBase.prototype._connect = function () {
|
|
|
168
165
|
CacheBase.prototype._loadData = function () {
|
|
169
166
|
try {
|
|
170
167
|
if (this.config.persist && this.file_path) {
|
|
171
|
-
this.log('info', `[_loadData] 尝试加载文件: ${this.file_path}`);
|
|
172
|
-
|
|
173
168
|
if (this.file_path.hasFile()) {
|
|
174
|
-
this.log('info', `[_loadData] 文件存在,开始读取`);
|
|
175
169
|
// 使用mm_expand的原型函数读取JSON文件
|
|
176
170
|
const parsed_data = this.file_path.loadJson();
|
|
177
|
-
this.log('info', `[_loadData] 文件读取成功,解析后的数据:`, Object.keys(parsed_data || {}));
|
|
178
|
-
|
|
179
171
|
if (parsed_data && parsed_data.data) {
|
|
180
172
|
this._data = parsed_data.data || {};
|
|
181
|
-
this.log('info', `[_loadData] 数据加载成功,键数量:`, Object.keys(this._data).length);
|
|
182
173
|
} else {
|
|
183
174
|
this.log('warn', `[_loadData] 解析后的数据中没有data字段`);
|
|
184
175
|
}
|
|
@@ -190,11 +181,7 @@ CacheBase.prototype._loadData = function () {
|
|
|
190
181
|
if (parsed_data && parsed_data.types) {
|
|
191
182
|
this._types = parsed_data.types || {};
|
|
192
183
|
}
|
|
193
|
-
} else {
|
|
194
|
-
this.log('info', `[_loadData] 文件不存在: ${this.file_path}`);
|
|
195
184
|
}
|
|
196
|
-
} else {
|
|
197
|
-
this.log('info', `[_loadData] 持久化未启用或文件路径未设置`);
|
|
198
185
|
}
|
|
199
186
|
} catch (error) {
|
|
200
187
|
this.log('error', '加载数据失败:', error);
|