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


Python Connection.get方法代码示例

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


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

示例1: get

# 需要导入模块: from couchbase._libcouchbase import Connection [as 别名]
# 或者: from couchbase._libcouchbase.Connection import get [as 别名]
    def get(self, key, ttl=0, quiet=None):
        """Obtain an object stored in Couchbase by given key.

        :param string key: The key to fetch. The type of key is the same
          as mentioned in :meth:`set`

        :param int ttl:
          If specified, indicates that the key's expiration time should be
          *modified* when retrieving the value.

        :param boolean quiet: causes `get` to return None instead of
          raising an exception when the key is not found. It defaults
          to the value set by
          :attr:`~couchbase.libcouchbase.Connection.quiet` on the instance.
          In `quiet` mode, the error may still be obtained by inspecting
          the :attr:`~couchbase.libcouchbase.Result.rc` attribute of the
          :class:`Result` object, or checking :attr:`Result.success`.

          Note that the default value is `None`, which means to use
          the :attr:`quiet`. If it is a boolean (i.e. `True` or `False) it will
          override the `Connection`-level `quiet` attribute.

        :raise: :exc:`couchbase.exceptions.NotFoundError` if the key
          is missing in the bucket
        :raise: :exc:`couchbase.exceptions.ConnectError` if the
          connection closed
        :raise: :exc:`couchbase.exceptions.ValueFormatError` if the
          value cannot be deserialized with chosen decoder, e.g. if you
          try to retreive an object stored with an unrecognized format
        :return: A :class:`~couchbase.libcouchbase.Result` object

        Simple get::

            value = cb.get('key').value

        Get multiple values::

            cb.get_multi(['foo', 'bar'])
            # { 'foo' : <Result(...)>, 'bar' : <Result(...)> }

        Inspect the flags::

            rv = cb.get("key")
            value, flags, cas = rv.value, rv.flags, rv.cas

        Update the expiration time::

            rv = cb.get("key", ttl=10)
            # Expires in ten seconds


        .. seealso::

        :meth:`get_multi`

        """

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

示例2: get

# 需要导入模块: from couchbase._libcouchbase import Connection [as 别名]
# 或者: from couchbase._libcouchbase.Connection import get [as 别名]
    def get(self, key, ttl=0, quiet=None, replica=False, no_format=False):
        """Obtain an object stored in Couchbase by given key.

        :param string key: The key to fetch. The type of key is the same
          as mentioned in :meth:`set`

        :param int ttl:
          If specified, indicates that the key's expiration time should be
          *modified* when retrieving the value.

        :param boolean quiet: causes `get` to return None instead of
          raising an exception when the key is not found. It defaults
          to the value set by
          :attr:`~couchbase.connection.Connection.quiet` on the instance.
          In `quiet` mode, the error may still be obtained by inspecting
          the :attr:`~couchbase.result.Result.rc` attribute of the
          :class:`couchbase.result.Result` object, or
          checking :attr:`couchbase.result.Result.success`.

          Note that the default value is `None`, which means to use
          the :attr:`quiet`. If it is a boolean (i.e. `True` or `False) it will
          override the :class:`Connection`-level :attr:`quiet` attribute.

        :param bool replica: Whether to fetch this key from a replica
          rather than querying the master server. This is primarily useful
          when operations with the master fail (possibly due to a configuration
          change). It should normally be used in an exception handler like so

          Using the ``replica`` option::

            try:
                res = c.get("key", quiet=True) # suppress not-found errors
            catch CouchbaseError:
                res = c.get("key", replica=True, quiet=True)


        :param bool no_format:

          .. versionadded:: 1.1.0

          If set to ``True``, then the value will always be
          delivered in the :class:`~couchbase.result.Result` object as being of
          :data:`~couchbase.FMT_BYTES`. This is a item-local equivalent of using
          the :attr:`data_passthrough` option


        :raise: :exc:`couchbase.exceptions.NotFoundError` if the key
          is missing in the bucket
        :raise: :exc:`couchbase.exceptions.ConnectError` if the
          connection closed
        :raise: :exc:`couchbase.exceptions.ValueFormatError` if the
          value cannot be deserialized with chosen decoder, e.g. if you
          try to retreive an object stored with an unrecognized format
        :return: A :class:`~couchbase.result.Result` object

        Simple get::

            value = cb.get('key').value

        Get multiple values::

            cb.get_multi(['foo', 'bar'])
            # { 'foo' : <Result(...)>, 'bar' : <Result(...)> }

        Inspect the flags::

            rv = cb.get("key")
            value, flags, cas = rv.value, rv.flags, rv.cas

        Update the expiration time::

            rv = cb.get("key", ttl=10)
            # Expires in ten seconds


        .. seealso::
            :meth:`get_multi`

        """

        return _Base.get(self, key, ttl, quiet, replica, no_format)
开发者ID:rayleyva,项目名称:couchbase-python-client,代码行数:83,代码来源:connection.py


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