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,22 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
CACHE_FILE = "config-cache.json"
|
||||
|
||||
|
||||
class Cache:
|
||||
def __init__(self, cache_dir: str = "."):
|
||||
self.cache_dir = cache_dir
|
||||
|
||||
def write(self, data: dict) -> None:
|
||||
path = os.path.join(self.cache_dir, CACHE_FILE)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False)
|
||||
|
||||
def read(self) -> dict | None:
|
||||
path = os.path.join(self.cache_dir, CACHE_FILE)
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return None
|
||||
Reference in New Issue
Block a user