MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetWithRev

Method GetWithRev

db/revision_cache_bypass.go:35–58  ·  view source on GitHub ↗

GetWithRev fetches the revision for the given docID and revID immediately from the bucket.

(ctx context.Context, docID, revID string, collectionID uint32, includeDelta bool)

Source from the content-addressed store, hash-verified

33
34// GetWithRev fetches the revision for the given docID and revID immediately from the bucket.
35func (rc *BypassRevisionCache) GetWithRev(ctx context.Context, docID, revID string, collectionID uint32, includeDelta bool) (docRev DocumentRevision, err error) {
36 doc, err := rc.backingStores[collectionID].GetDocument(ctx, docID, DocUnmarshalSync)
37 if err != nil {
38 return DocumentRevision{}, err
39 }
40
41 docRev = DocumentRevision{
42 RevID: revID,
43 RevCacheValueDeltaLock: &sync.Mutex{}, // initialize the mutex for delta updates
44 }
45 var hlv *HybridLogicalVector
46 docRev.BodyBytes, docRev.History, docRev.Channels, docRev.Removed, docRev.Attachments, docRev.Deleted, docRev.Expiry, hlv, err = revCacheLoaderForDocument(ctx, rc.backingStores[collectionID], doc, revID)
47 if err != nil {
48 return DocumentRevision{}, err
49 }
50 if hlv != nil {
51 docRev.CV = hlv.ExtractCurrentVersionFromHLV()
52 docRev.HlvHistory = hlv.ToHistoryForHLV()
53 }
54
55 rc.bypassStat.Add(1)
56
57 return docRev, nil
58}
59
60// GetWithCV fetches the Current Version for the given docID and CV immediately from the bucket.
61func (rc *BypassRevisionCache) GetWithCV(ctx context.Context, docID string, cv *Version, collectionID uint32, includeDelta bool, loadBackup bool) (docRev DocumentRevision, err error) {

Callers 1

TestBypassRevisionCacheFunction · 0.95

Calls 5

ToHistoryForHLVMethod · 0.95
GetDocumentMethod · 0.65
AddMethod · 0.45

Tested by 1

TestBypassRevisionCacheFunction · 0.76