client.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:tornetcd 作者: mqingyn 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号