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

Method addToRevMapPostLoad

db/revision_cache_lru.go:455–478  ·  view source on GitHub ↗

addToRevMapPostLoad will generate and entry in the Rev lookup map for a new document entering the cache

(ctx context.Context, docID, revID string, cv *Version, collectionID uint32)

Source from the content-addressed store, hash-verified

453
454// addToRevMapPostLoad will generate and entry in the Rev lookup map for a new document entering the cache
455func (rc *LRURevisionCache) addToRevMapPostLoad(ctx context.Context, docID, revID string, cv *Version, collectionID uint32) {
456 if revID == "" {
457 // no revID to map to, exit early
458 return
459 }
460 legacyKey := IDAndRev{DocID: docID, RevID: revID, CollectionID: collectionID}
461 key := IDandCV{DocID: docID, Source: cv.SourceID, Version: cv.Value, CollectionID: collectionID}
462
463 rc.lock.Lock()
464 defer rc.lock.Unlock()
465 // check for existing value in rev cache map (due to concurrent fetch by rev ID)
466 cvElem, cvFound := rc.hlvCache[key]
467 _, revFound := rc.cache[legacyKey]
468 if !cvFound {
469 // its possible the element has been evicted if we don't find the element above (high churn on rev cache)
470 // need to return doc revision to caller still but no need repopulate the cache
471 return
472 }
473 // Check if another goroutine has already updated the rev map
474 if !revFound {
475 // if not found we need to add the element to the rev lookup (for PUT code path)
476 rc.cache[legacyKey] = cvElem
477 }
478}
479
480// addToHLVMapPostLoad will generate and entry in the CV lookup map for a new document entering the cache
481func (rc *LRURevisionCache) addToHLVMapPostLoad(ctx context.Context, docID, revID string, cv *Version, collectionID uint32) {

Callers 2

getFromCacheByCVMethod · 0.95
PutMethod · 0.95

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected