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

Method getFromCacheByCV

db/revision_cache_lru.go:237–260  ·  view source on GitHub ↗
(ctx context.Context, docID string, cv *Version, collectionID uint32, loadCacheOnMiss bool, includeDelta bool, loadBackup bool)

Source from the content-addressed store, hash-verified

235}
236
237func (rc *LRURevisionCache) getFromCacheByCV(ctx context.Context, docID string, cv *Version, collectionID uint32, loadCacheOnMiss bool, includeDelta bool, loadBackup bool) (DocumentRevision, error) {
238 value := rc.getValueByCV(ctx, docID, cv, collectionID, loadCacheOnMiss)
239 if value == nil {
240 return DocumentRevision{}, nil
241 }
242
243 // for CV pathway we respect the loadBackup flag passed in
244 docRev, cacheHit, err := value.load(ctx, rc.backingStores[collectionID], includeDelta, loadBackup)
245 rc.statsRecorderFunc(cacheHit)
246
247 if err != nil {
248 rc.removeValue(value, collectionID) // don't keep failed loads in the cache
249 }
250
251 if !cacheHit && err == nil {
252 // cache miss so we had to load doc, increment memory count
253 rc.incrRevCacheMemoryUsage(ctx, value.getItemBytes())
254 // check for memory based eviction
255 rc.revCacheMemoryBasedEviction(ctx)
256 rc.addToRevMapPostLoad(ctx, docID, docRev.RevID, docRev.CV, collectionID)
257 }
258
259 return docRev, err
260}
261
262// Attempts to retrieve the active revision for a document from the cache. Requires retrieval
263// of the document from the bucket to guarantee the current active revision, but does minimal unmarshalling

Callers 1

GetWithCVMethod · 0.95

Calls 8

getValueByCVMethod · 0.95
statsRecorderFuncMethod · 0.95
removeValueMethod · 0.95
addToRevMapPostLoadMethod · 0.95
getItemBytesMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected