Only write to etcd if values have changed

This prevents certain loops from writing data to etcd every few
seconds (when data hasn't changed).
code is only used once, you can just put scheme at the second field in the following line (codec is also defined globally in this package, making this use shadow that one is confusing).