本文整理汇总了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)