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

Method removeFromCacheByCV

db/revision_cache_lru.go:528–549  ·  view source on GitHub ↗

removeFromCacheByCV removes an entry from rev cache by CV

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

Source from the content-addressed store, hash-verified

526
527// removeFromCacheByCV removes an entry from rev cache by CV
528func (rc *LRURevisionCache) removeFromCacheByCV(ctx context.Context, docID string, cv *Version, collectionID uint32) {
529 key := IDandCV{DocID: docID, Source: cv.SourceID, Version: cv.Value, CollectionID: collectionID}
530 rc.lock.Lock()
531 defer rc.lock.Unlock()
532 element, ok := rc.hlvCache[key]
533 if !ok {
534 return
535 }
536 // grab the revid key from the value to enable us to remove the reference from the rev lookup map too
537 elem, ok := element.Value.(*revCacheValue)
538 if !ok {
539 return
540 }
541
542 legacyKey := IDAndRev{DocID: docID, RevID: elem.revID, CollectionID: collectionID}
543 rc.lruList.Remove(element)
544 delete(rc.hlvCache, key)
545 // remove from rev lookup map too
546 delete(rc.cache, legacyKey)
547 rc._decrRevCacheMemoryUsage(ctx, -elem.getItemBytes())
548 rc.cacheNumItems.Add(-1)
549}
550
551// removeFromCacheByRev removes an entry from rev cache by revID
552func (rc *LRURevisionCache) removeFromCacheByRev(ctx context.Context, docID, revID string, collectionID uint32) {

Callers 1

RemoveWithCVMethod · 0.95

Calls 6

getItemBytesMethod · 0.80
RemoveMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected