When I set a key in consul, e.g.:
curl -w "\n" -v --request PUT --data value http://127.0.0.1:8500/v1/kv/my-key?cas=1234
How can I get the index for the value I just set? I was surprised to see the response doesn't contain the header X-Consul-Index (why not?).
If I issue another request, e.g.:
curl -w "\n" -v http://127.0.0.1:8500/v1/kv/my-key
I will get the index for the current value but there are two problems with that:
- It's a race condition. The key could have been changed in the meantime and I'll get a different index.
- It's wasteful, the response should have that info.
What's the correct way of setting a key/value and knowing the index?