What is the main store of valuables on the couch

I'm new to coucbase, I have some doubts about storing key values โ€‹โ€‹in couchbase. We usually store data as a document. I need clarification for the following queries,

  • What is the difference between document type and key type?
  • How can I get the keystore? Can you explain with a small example.
  • What is the advantage of storing as a key value?
+3


source to share


1 answer


  • What is the difference between document type and key type?

In Couchbase, you can store any key / value pairs. At this level, keys and values โ€‹โ€‹are just byte arrays. However, if the value you are storing is valid JSON, then additional functionality (like views) appears that becomes available. You can mix and match in the same bucket. It is sometimes useful to use whole counters or comma-separated string lists alongside third party regular JSON documents in the same bucket. Note, however, that the Couchbase Elasticsearch adapter ONLY works with JSON documents. If you store simple items / values โ€‹โ€‹in a bucket, they will be ignored by the Elasticsearch adapter.

  • How can I get the keystore? 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 advantage of storing as a key value?



Typically, the advantage is maximum performance for several reasons.

  • you don't need to JSON encode / decode the Operation value
  • such as Incr () only work on values โ€‹โ€‹that are integers Operations
  • such as Append () only work on values โ€‹โ€‹that are strings
  • The use of these operations are special case-specific operations that can allow you to avoid Get / Set / Cas repeat operations
+3


source







All Articles