欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

etcd 教程 - 1. 写入数据

最编程 2024-05-03 12:51:43
...
// 连接etcd
Client client = Client.builder().endpoints("http://localhost:2379").build();
// 获取KV client
KV kvClient = client.getKVClient();

// 设置Key = "/tizi"
ByteSequence key = ByteSequence.from(new String("/tizi").getBytes("utf-8"));

// 设置value = "test_value"
ByteSequence value = ByteSequence.from("test_value".getBytes("utf-8"));

// 将key和value写入到etcd
kvClient.put(key, value).get();

提示:java etcd依赖配置,请参考连接etcd章节

推荐阅读