标签: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}
标签:bsp val python one int odi ssi ttl nbsp
原文地址:http://www.cnblogs.com/mhc-fly/p/6918005.html