Format readme.md

Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2023-06-30 15:37:27 +08:00
parent fcc5807748
commit 09f665fe3e
1 changed files with 18 additions and 18 deletions

View File

@ -569,26 +569,26 @@ keys defined by the prefix. mkdir method is removed since etcdv3 treats everythi
3. Removing directory: 3. Removing directory:
If you want the delete recursively then you have to pass a second `true` parameter If you want the delete recursively then you have to pass a second `true` parameter
to rmdir and supply a key. This key will be treated as a prefix. All keys that match the to rmdir and supply a key. This key will be treated as a prefix. All keys that match the
prefix will be deleted. All deleted keys will be placed in `response.values()` and prefix will be deleted. All deleted keys will be placed in `response.values()` and
`response.keys()`. This parameter defaults to `false`. `response.keys()`. This parameter defaults to `false`.
```c++ ```c++
etcd::Client etcd("http://127.0.0.1:2379"); etcd::Client etcd("http://127.0.0.1:2379");
etcd.set("/test/key1", "foo"); etcd.set("/test/key1", "foo");
etcd.set("/test/key2", "bar"); etcd.set("/test/key2", "bar");
etcd.set("/test/key3", "foo_bar"); etcd.set("/test/key3", "foo_bar");
etcd::Response resp = etcd.rmdir("/test", true).get(); etcd::Response resp = etcd.rmdir("/test", true).get();
for (int i = 0; i < resp.keys().size(); ++i) for (int i = 0; i < resp.keys().size(); ++i)
{ {
std::cout << resp.keys(i); std::cout << resp.keys(i);
std::cout << " = " << resp.value(i).as_string() << std::endl; std::cout << " = " << resp.value(i).as_string() << std::endl;
} }
``` ```
However, if recursive parameter is false, functionality will be the same as just deleting a key. However, if recursive parameter is false, functionality will be the same as just deleting a key.
The key supplied will NOT be treated as a prefix and will be treated as a normal key name. The key supplied will NOT be treated as a prefix and will be treated as a normal key name.
### Using binary data as key and value ### Using binary data as key and value