Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-31401

Support returning deleted values using the subdoc api (array pop-like functionality)

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • master
    • memcached
    • None

    Description

      There is a fairly common usecase where users want to use arrays within documents as a form of queue/stack etc.
      Generally in this use-case you want to 'pop' an element from an array which means you want to return the element to the user and simultaneously remove it from the array.

      Today this is possible but it takes at least 2 separate operations (I say at least because to be thread-safe it has to use CAS, which means it could be repeated many times due to mismatches).
      Given that technically KV Engine is capable (or could be made capable) of performing this logic, it would be nice if it exposed a way to either return a deleted element via the subdoc API or exposed a new subdoc opcode.

      This would have the side-benefit of simplifying and speeding up the queue datastructure exposed by our own SDKs.
      The code in the .NET SDK (for example), uses the approach I explained above https://github.com/couchbase/couchbase-net-client/blob/master/Src/Couchbase/Collections/CouchbaseQueue.cs#L30.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shivani.gupta Shivani Gupta
            matt.carabine Matt Carabine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty