> On Apr 20, 2015, at 10:56 AM, Frederic Yesid Peña Sánchez 
> <[email protected]> wrote:
> 
> While reading the compaction code, i notice it removes the revisions who 
> reside on separate documents.
> How are the revisions stored in Sync/Couchbase?

The key “foo” in the bucket maps to document “foo” in the database. It contains 
an extra internal property “_sync” that stores metadata the Gateway uses. 
Inside that, “revisions” (sp?) stores the revision tree in a weird encoding 
that was designed to save space.

The revision tree only stores a revision’s body if it’s an active conflict. 
Other revisions (ones that have been updated) have their bodies moved out into 
separate docs in the bucket, whose keys are of the form “_sync:rev:” followed 
by the docID and revID. These docs have an expiration time of 5 minutes so 
Couchbase Server cleans them up automatically.

The revision tree itself gets ‘pruned’ during every document update. Nodes that 
are too far from any leaf are deleted. Note that active conflicts are leaves, 
so if the doc has a lot of conflicts going back through its history, they’ll 
effectively keep anything from getting pruned.

—Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/7994C797-D51E-4180-88BA-8E38F7F51426%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to