feat: 添加多语言客户端 Docker 支持
- 新增 .NET 客户端 SDK 和 demo 项目 - 添加 Go/Node.js/Python/.NET/SpringBoot2 的 Dockerfile - Go demo 支持从环境变量读取配置 - 创建 README_DOCKERFILE.md 文档说明 Docker 使用方法 - 更新根目录 README.md 标记 .NET 客户端为已支持
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kenaito.Conf.Client;
|
||||
|
||||
internal class Cache
|
||||
{
|
||||
private readonly string _cacheFile;
|
||||
|
||||
public Cache(string cacheDir)
|
||||
{
|
||||
_cacheFile = Path.Combine(cacheDir, "config-cache.json");
|
||||
}
|
||||
|
||||
public Dictionary<string, object>? Read()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_cacheFile))
|
||||
return null;
|
||||
var json = File.ReadAllText(_cacheFile);
|
||||
return JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(Dictionary<string, object> data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(data, Formatting.Indented);
|
||||
File.WriteAllText(_cacheFile, json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore cache write errors
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user