removeFromCacheByRev removes an entry from rev cache by revID
(ctx context.Context, docID, revID string, collectionID uint32)
| 550 | |
| 551 | // removeFromCacheByRev removes an entry from rev cache by revID |
| 552 | func (rc *LRURevisionCache) removeFromCacheByRev(ctx context.Context, docID, revID string, collectionID uint32) { |
| 553 | key := IDAndRev{DocID: docID, RevID: revID, CollectionID: collectionID} |
| 554 | rc.lock.Lock() |
| 555 | defer rc.lock.Unlock() |
| 556 | element, ok := rc.cache[key] |
| 557 | if !ok { |
| 558 | return |
| 559 | } |
| 560 | // grab the cv key from the value to enable us to remove the reference from the rev lookup map too |
| 561 | elem, ok := element.Value.(*revCacheValue) |
| 562 | if !ok { |
| 563 | return |
| 564 | } |
| 565 | |
| 566 | hlvKey := IDandCV{DocID: docID, Source: elem.cv.SourceID, Version: elem.cv.Value, CollectionID: collectionID} |
| 567 | rc.lruList.Remove(element) |
| 568 | // decrement the overall memory bytes count |
| 569 | rc._decrRevCacheMemoryUsage(ctx, -elem.getItemBytes()) |
| 570 | delete(rc.cache, key) |
| 571 | // remove from CV lookup map too |
| 572 | delete(rc.hlvCache, hlvKey) |
| 573 | rc.cacheNumItems.Add(-1) |
| 574 | } |
| 575 | |
| 576 | // removeFromRevLookup will only remove the entry from the rev lookup map, if present. Underlying element must stay in list for eviction to work. |
| 577 | func (rc *LRURevisionCache) removeFromRevLookup(ctx context.Context, docID, revID string, collectionID uint32) { |
no test coverage detected