def test_and_set(self, key, value, prev_value, ttl=None, callback=None):
"""
Atomic test & set operation.
It will check if the value of 'key' is 'prev_value',
if the the check is correct will change the value for 'key' to 'value'
if the the check is false an exception will be raised.
Args:
key (str): Key.
value (object): value to set
prev_value (object): previous value.
ttl (int): Time in seconds of expiration (optional).
Returns:
client.EtcdResult
Raises:
ValueError: When the 'prev_value' is not the current value.
>>> print client.test_and_set('/key', 'new', 'old', ttl=60).value
'new'
"""
return self.write(key, value, prevValue=prev_value, ttl=ttl, callback=callback)
评论列表
文章目录