def touch(self,
              id,  # type: str
              *options,  # type: TouchOptions
              **kwargs):
        # type: (...)->MutationResult
        """Update a key's expiration time

        :param string key: The key whose expiration time should be
            modified
        :param int timeout: The new expiration time. If the expiration time
            is `0` then the key never expires (and any existing
            expiration is removed)
        :return: :class:`.OperationResult`

        Update the expiration time of a key ::

            cb.upsert("key", expiration=Seconds(100))
            # expires in 100 seconds
            cb.touch("key", expiration=Seconds(0))
            # key should never expire now

        :raise: The same things that :meth:`get` does

        .. seealso:: :meth:`get` - which can be used to get *and* update the
            expiration
        """
        return _Base.touch(self.bucket, id, **forward_args(kwargs, *options))
Exemple #2
0
    def touch(self, key, ttl=0):
        """Update a key's expiry time

        :param string key: The key whose expiry time should be
            modified
        :param int ttl: The new expiry time. If the expiry time
            is `0` then the key never expires (and any existing
            expiry is removed)
        :return: :class:`.OperationResult`

        Update the expiry time of a key ::

            cb.upsert("key", ttl=100)
            # expires in 100 seconds
            cb.touch("key", ttl=0)
            # key should never expire now

        :raise: The same things that :meth:`get` does

        .. seealso:: :meth:`get` - which can be used to get *and* update the
            expiry, :meth:`touch_multi`
        """
        return _Base.touch(self, key, ttl=ttl)