沙发底座的关键值存储量是多少 [英] What is the key value storage in couch base

查看:43
本文介绍了沙发底座的关键值存储量是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是coucbase的新手,我对沙发床中的键值存储有些疑问.通常我们将数据存储为文档.我需要澄清以下查询,

I am new with coucbase,i have some doubt regarding the key value storage in couchbase. Normally we store data as document. I need clarification for bellow queries ,

  • 文档类型和键值类型有什么区别?
  • 我如何实现键值存储?您能用一个小例子来解释一下吗?
  • 将其存储为键值有什​​么好处?

推荐答案

  • 文档类型和键值类型有什么区别?
  • 在Couchbase中,您可以存储任何键/值对.在此级别上,键和值只是字节数组.但是,如果您存储的值恰好是有效的JSON,则可以使用其他功能(例如视图).您可以在同一个桶中混合搭配.有时,在同一存储桶中,将整数计数器或以逗号分隔的字符串列表与常规JSON文档一起使用会很有用.但是请注意,Couchbase Elasticsearch适配器仅适用于JSON文档.如果您将简单键/值项存储在存储桶中,Elasticsearch适配器将忽略它们.

    In Couchbase you can store any key/value pairs. At this level keys and values are just byte arrays. However, if the value you store happens to be valid JSON, then there is additional functionality (such as views) that become available. You can mix and match within the same bucket. Sometimes its useful to use integer counters, or comma-delimited string lists along side regular JSON documents in the same bucket. Note however that the Couchbase Elasticsearch adapter ONLY works with JSON documents. If you store plain key/value items in a bucket, they will be ignored by the Elasticsearch adapter.

    • 我如何实现键值存储?你能用一个小例子来解释.

    • How can i achieve key - value storage ? Can you explain with a small example.

        // Connect to localhost or to the appropriate     
        URIuris.add(URI.create("http://localhost:8091/pools"));
        CouchbaseClient client = null;
        client = new CouchbaseClient(uris, "streams", "");
        client.add("1234", "xxx");
        client.replace("1234", "1234");
        Object data = client.get("1234");
        System.out.println(data.toString());
        client.delete("1234");
    

  • 将其存储为键值有什​​么好处?

  • what is the benefit of storing as key-value?

    通常,出于以下几个原因,好处是可以实现最高性能.

    Typically the benefit is maximum performance for a couple of reasons.

    1. 您不需要对值进行JSON编码/解码
    2. 类似Incr()的操作仅适用于整数值
    3. 类似Append()的操作仅适用于字符串值
    4. 使用这些操作是特殊情况下的操作,可让您避免执行Get/Set/Cas重试操作

    这篇关于沙发底座的关键值存储量是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆