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

Method removeValue

db/revision_cache_lru.go:597–618  ·  view source on GitHub ↗

removeValue removes a value from the revision cache, if present and the value matches the the value. If there's an item in the revision cache with a matching docID and revID but the document is different, this item will not be removed from the rev cache.

(value *revCacheValue, collectionID uint32)

Source from the content-addressed store, hash-verified

595
596// removeValue removes a value from the revision cache, if present and the value matches the the value. If there's an item in the revision cache with a matching docID and revID but the document is different, this item will not be removed from the rev cache.
597func (rc *LRURevisionCache) removeValue(value *revCacheValue, collectionID uint32) {
598 rc.lock.Lock()
599 defer rc.lock.Unlock()
600 revKey := IDAndRev{DocID: value.id, RevID: value.revID, CollectionID: collectionID}
601 var itemRemoved bool
602 if element := rc.cache[revKey]; element != nil && element.Value == value {
603 rc.lruList.Remove(element)
604 delete(rc.cache, revKey)
605 itemRemoved = true
606 }
607 // need to also check hlv lookup cache map
608 hlvKey := IDandCV{DocID: value.id, Source: value.cv.SourceID, Version: value.cv.Value, CollectionID: collectionID}
609 if element := rc.hlvCache[hlvKey]; element != nil && element.Value == value {
610 rc.lruList.Remove(element)
611 delete(rc.hlvCache, hlvKey)
612 itemRemoved = true
613 }
614
615 if itemRemoved {
616 rc.cacheNumItems.Add(-1)
617 }
618}
619
620// _numberCapacityEviction will iterate removing the last element in cache til we fall below the maximum number of items
621// threshold for this shard, retuning the bytes evicted and number of items evicted

Callers 3

getFromCacheByRevMethod · 0.95
getFromCacheByCVMethod · 0.95
GetActiveMethod · 0.95

Calls 4

RemoveMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected