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

Function revCacheLoaderForDocumentCV

db/revision_cache_interface.go:474–494  ·  view source on GitHub ↗

revCacheLoaderForDocumentCV used either during cache miss (from revCacheLoaderForCv), or used directly when getting current active CV from cache nolint:staticcheck

(ctx context.Context, backingStore RevisionCacheBackingStore, doc *Document, cv Version, loadBackup bool)

Source from the content-addressed store, hash-verified

472// revCacheLoaderForDocumentCV used either during cache miss (from revCacheLoaderForCv), or used directly when getting current active CV from cache
473// nolint:staticcheck
474func revCacheLoaderForDocumentCV(ctx context.Context, backingStore RevisionCacheBackingStore, doc *Document, cv Version, loadBackup bool) (bodyBytes []byte, history Revisions, channels base.Set, removed bool, attachments AttachmentsMeta, deleted bool, expiry *time.Time, revid string, hlv *HybridLogicalVector, err error) {
475 if bodyBytes, attachments, channels, deleted, err = backingStore.getCurrentVersion(ctx, doc, cv, loadBackup); err != nil {
476 return nil, nil, nil, false, nil, false, nil, "", nil, err
477 }
478
479 // if we have request current version on the doc we can add revision ID too. If not we cannot know what the
480 // corresponding revID is to pair with the request CV
481 if doc.HLV.ExtractCurrentVersionFromHLV().Equal(cv) {
482 revid = doc.GetRevTreeID()
483 deleted = doc.Deleted
484 hlv = doc.HLV
485 }
486
487 validatedHistory, getHistoryErr := doc.History.getHistory(revid)
488 if getHistoryErr != nil {
489 return bodyBytes, history, channels, removed, attachments, deleted, doc.Expiry, revid, hlv, err
490 }
491 history = encodeRevisions(ctx, doc.ID, validatedHistory)
492
493 return bodyBytes, history, channels, removed, attachments, deleted, doc.Expiry, revid, hlv, err
494}
495
496func (c *DatabaseCollection) getCurrentVersion(ctx context.Context, doc *Document, cv Version, loadBackup bool) (bodyBytes []byte, attachments AttachmentsMeta, channels base.Set, deleted bool, err error) {
497 if err = doc.HasCurrentVersion(ctx, cv); err != nil {

Callers 3

revCacheLoaderForCvFunction · 0.85
GetWithCVMethod · 0.85
loadForDocMethod · 0.85

Calls 6

encodeRevisionsFunction · 0.85
getHistoryMethod · 0.80
getCurrentVersionMethod · 0.65
EqualMethod · 0.45
GetRevTreeIDMethod · 0.45

Tested by

no test coverage detected