Getting only metadata of a Document


#1

Hi,

I’m trying to find a way for getting only the metadata for a document (especially Cas value) for using it at Couchbase sub-document. As described here : http://blog.couchbase.com/2016/may/couchbase-server-45s-new-sub-document
for optimistic locking I need to work with “withCas” option, but for getting the Cas I need to do getDocument. If I do it I almost don’t get any better performance VS working in the standard way, because I do full get including the content which may access to the disk.
Does anyone know if there is a possibility to get only document metadata?

Thanks,
Asaf.


#2

You most probably want to do optimistic locking from a point of reference? If that’s the last mutation applied with subdoc, then I guess the only problematic step is the initial mutation?

In any case, you could use subdoc again and do a lookupIn(key).exists("someField"). The resulting DocumentFragment<Lookup> will have the document’s CAS, and that will be lighter on IO than a get.


#3

Hi,

Does lookupIn(key).exists(“Cas”) will work, or I must give a Json content field?
If no, what you described it faster than full get, but still may required access to disk.

Thanks,
Asaf.


#4

ah, yes it’ll still require access to disk if the document has been offloaded to disk…