Details
-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
master
-
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.