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)
| 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. |
| 597 | func (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 |
no test coverage detected