refactor: 客户端目录统一添加 kenaito-conf- 前缀
- go-client → kenaito-conf-go-client - python-client → kenaito-conf-python-client - python-client-demo → kenaito-conf-python-client-demo - nodejs-client → kenaito-conf-nodejs-client - nodejs-client-demo → kenaito-conf-nodejs-client-demo - 更新所有 README 和 package.json 中的路径引用
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const CACHE_FILE = 'config-cache.json';
|
||||
|
||||
export class Cache {
|
||||
constructor(cacheDir = '.') {
|
||||
this.cacheDir = cacheDir;
|
||||
}
|
||||
|
||||
write(data) {
|
||||
const filePath = path.join(this.cacheDir, CACHE_FILE);
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
|
||||
}
|
||||
|
||||
read() {
|
||||
const filePath = path.join(this.cacheDir, CACHE_FILE);
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
return JSON.parse(content);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user