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

Method GetActive

db/revision_cache_bypass.go:88–113  ·  view source on GitHub ↗

GetActive fetches the active revision for the given docID immediately from the bucket.

(ctx context.Context, docID string, collectionID uint32)

Source from the content-addressed store, hash-verified

86
87// GetActive fetches the active revision for the given docID immediately from the bucket.
88func (rc *BypassRevisionCache) GetActive(ctx context.Context, docID string, collectionID uint32) (docRev DocumentRevision, err error) {
89
90 doc, err := rc.backingStores[collectionID].GetDocument(ctx, docID, DocUnmarshalSync)
91 if err != nil {
92 return DocumentRevision{}, err
93 }
94
95 docRev = DocumentRevision{
96 RevID: doc.GetRevTreeID(),
97 RevCacheValueDeltaLock: &sync.Mutex{}, // initialize the mutex for delta updates
98 }
99
100 var hlv *HybridLogicalVector
101 docRev.BodyBytes, docRev.History, docRev.Channels, docRev.Removed, docRev.Attachments, docRev.Deleted, docRev.Expiry, hlv, err = revCacheLoaderForDocument(ctx, rc.backingStores[collectionID], doc, doc.SyncData.GetRevTreeID())
102 if err != nil {
103 return DocumentRevision{}, err
104 }
105 if hlv != nil {
106 docRev.CV = hlv.ExtractCurrentVersionFromHLV()
107 docRev.HlvHistory = hlv.ToHistoryForHLV()
108 }
109
110 rc.bypassStat.Add(1)
111
112 return docRev, nil
113}
114
115// Peek is a no-op for a BypassRevisionCache, and always returns a false 'found' value.
116func (rc *BypassRevisionCache) Peek(ctx context.Context, docID, revID string, collectionID uint32) (docRev DocumentRevision, found bool) {

Callers 1

TestBypassRevisionCacheFunction · 0.95

Calls 6

ToHistoryForHLVMethod · 0.95
GetDocumentMethod · 0.65
GetRevTreeIDMethod · 0.45
AddMethod · 0.45

Tested by 1

TestBypassRevisionCacheFunction · 0.76