当前位置: 首页>>代码示例>>Python>>正文


Python Connection.delete方法代码示例

本文整理汇总了Python中couchbase._libcouchbase.Connection.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.delete方法的具体用法?Python Connection.delete怎么用?Python Connection.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在couchbase._libcouchbase.Connection的用法示例。


在下文中一共展示了Connection.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from couchbase._libcouchbase import Connection [as 别名]
# 或者: from couchbase._libcouchbase.Connection import delete [as 别名]
    def delete(self, key, cas=0, quiet=None):
        """Remove the key-value entry for a given key in Couchbase.

        :param key: A string which is the key to delete. The format and type
          of the key follows the same conventions as in :meth:`set`

        :type key: string, dict, or tuple/list
        :param int cas: The CAS to use for the removal operation.
          If specified, the key will only be deleted from the server if
          it has the same CAS as specified. This is useful to delete a
          key only if its value has not been changed from the version
          currently visible to the client.
          If the CAS on the server does not match the one specified,
          an exception is thrown.
        :param boolean quiet:
          Follows the same semantics as `quiet` in :meth:`get`

        :raise: :exc:`couchbase.exceptions.NotFoundError` if the key
          does not exist on the bucket
        :raise: :exc:`couchbase.exceptions.KeyExistsError` if a CAS
          was specified, but the CAS on the server had changed
        :raise: :exc:`couchbase.exceptions.ConnectError` if the
          connection was closed

        :return: A :class:`~couchbase.libcouchbase.Result` object.


        Simple delete::

            ok = cb.delete("key").success

        Don't complain if key does not exist::

            ok = cb.delete("key", quiet=True)

        Only delete if CAS matches our version::

            rv = cb.get("key")
            cb.delete("key", cas=rv.cas)

        Remove multiple keys::

            oks = cb.delete_multi(["key1", "key2", "key3"])

        Remove multiple keys with CAS::

            oks = cb.delete({
                "key1" : cas1,
                "key2" : cas2,
                "key3" : cas3
            })


        .. seealso::

        :meth:`delete_multi`

        """
        return _Base.delete(self, key, cas, quiet)
开发者ID:sublee,项目名称:couchbase-python-client,代码行数:61,代码来源:libcouchbase.py


注:本文中的couchbase._libcouchbase.Connection.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。