GetActive fetches the active revision for the given docID immediately from the bucket.
(ctx context.Context, docID string, collectionID uint32)
| 86 | |
| 87 | // GetActive fetches the active revision for the given docID immediately from the bucket. |
| 88 | func (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. |
| 116 | func (rc *BypassRevisionCache) Peek(ctx context.Context, docID, revID string, collectionID uint32) (docRev DocumentRevision, found bool) { |