刷新目录过期时间
代码语言:javascript
复制[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true
1454394195
{"action":"set","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:25.962070512Z","ttl":10,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir
1454394200
{"action":"get","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:25.962070512Z","ttl":6,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true -d prevExist=true
1454394202
{"action":"update","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:32.096351254Z","ttl":10,"modifiedIndex":86,"createdIndex":85},"prevNode":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:25.962070512Z","ttl":4,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir
1454394204
{"action":"get","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:32.096351254Z","ttl":8,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true -d prevExist=true
1454394209
{"action":"update","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:39.280877021Z","ttl":10,"modifiedIndex":87,"createdIndex":85},"prevNode":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:32.096351254Z","ttl":3,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir
1454394211
{"action":"get","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:39.280877021Z","ttl":8,"modifiedIndex":85,"createdIndex":85}}
[root@docker ~]# date %s ;curl http://127.0.0.1:2379/v2/keys/testdir
1454394356
{"errorCode":100,"message":"Key not found","cause":"/testdir","index":88}
[root@docker ~]#