码迷,mamicode.com
首页 > 其他好文 > 详细

租约的使用和基本操作

时间:2019-12-20 01:10:46      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:并且   content   ant   key   https   star   bottom   tac   tag   

技术图片

技术图片

/go # etcdctl lease grant 200 //设置一个200秒过期的租约
lease 08e86eea8129eb12 granted with TTL(200s)
/go # etcdctl lease timetolive 08e86eea8129eb12 //查看该租约的剩余到期时间
lease 08e86eea8129eb12 granted with TTL(200s), remaining(153s)
/go # etcdctl lease revoke 08e86eea8129eb12 //删除租约
lease 08e86eea8129eb12 revoked
/go # etcdctl lease grant 200 //创建一个时长200秒的租约
lease 08e86eea8129eb17 granted with TTL(200s)
/go # etcdctl lease timetolive 08e86eea8129eb17 //查看租约剩余时间
lease 08e86eea8129eb17 granted with TTL(200s), remaining(181s)
/go # etcdctl  put /user xiahualou --lease 08e86eea8129eb17 //插入一条数据并且关联到租约08e86eea8129eb17
OK
/go # etcdctl get /user
/user
xiahualou
/go # etcdctl lease timetolive 08e86eea8129eb17
lease 08e86eea8129eb17 granted with TTL(200s), remaining(114s)
/go # etcdctl lease timetolive 08e86eea8129eb17 //租约还没到期
lease 08e86eea8129eb17 granted with TTL(200s), remaining(65s)
/go # etcdctl  put /user2 lisiyi --lease 08e86eea8129eb17 //插入一条数据
OK
/go # etcdctl lease timetolive 08e86eea8129eb12 --keys //租约已经过期了
lease 08e86eea8129eb12 already expired
/go # etcdctl lease timetolive 08e86eea8129eb17 --keys //查看该租约下的key
lease 08e86eea8129eb17 granted with TTL(200s), remaining(4s), attached keys([/user /user2])
/go # etcdctl lease timetolive 08e86eea8129eb17
lease 08e86eea8129eb17 already expired
/go # etcdctl get /user //租约过期了查不到数据
/go # etcdctl get /user1 //租约过期了查不到数据
/go # etcdctl lease keep-alive 08e86eea8129eb17 //过期之后不可以续租,只能过期前续租,续租成功又恢复到满租时长
lease 08e86eea8129eb17 expired or revoked.




租约的使用和基本操作

标签:并且   content   ant   key   https   star   bottom   tac   tag   

原文地址:https://www.cnblogs.com/hualou/p/12071059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!