码迷,mamicode.com
首页 > 编程语言 > 详细

python-consul

时间:2017-05-29 15:17:09      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:bsp   val   python   one   int   odi   ssi   ttl   nbsp   

import consul

c = consul.Consul(host="192.168.111.111")

c.kv.put("key","value")

a = c.kv.get("key")

print a

(‘107‘, {u‘LockIndex‘: 0, u‘ModifyIndex‘: 107, u‘Value‘: ‘value‘, u‘Flags‘: 0, u‘Key‘: u‘key‘, u‘CreateIndex‘: 107})

 

a = c.session.create(name="mhc",behavior=‘release‘,ttl=25)
c.kv.put("key111", "v2222", acquire=a)
b = c.kv.get("key111")[1]
print b

{u‘LockIndex‘: 1, u‘ModifyIndex‘: 332, u‘Value‘: ‘v2222‘, u‘Session‘: u‘63d76352-f2ee-8cf0-8c01-b91581d22c1a‘, u‘Flags‘: 0, u‘Key‘: u‘key111‘, u‘CreateIndex‘: 332}

 

a = c.session.create(name="mhc",behavior=‘release‘,ttl=25)
c.kv.put("key111", "v2222", acquire=a)
time.sleep(2)
print c.kv.put("key111", "done", release=a)
b = c.kv.get("key111")[1]
print b

 

True

{u‘LockIndex‘: 3, u‘ModifyIndex‘: 368, u‘Value‘: ‘done‘, u‘Flags‘: 0, u‘Key‘: u‘key111‘, u‘CreateIndex‘: 332}

python-consul

标签:bsp   val   python   one   int   odi   ssi   ttl   nbsp   

原文地址:http://www.cnblogs.com/mhc-fly/p/6918005.html

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