(ctx context.Context, docID string, cv *Version, collectionID uint32, create bool)
| 421 | } |
| 422 | |
| 423 | func (rc *LRURevisionCache) getValueByCV(ctx context.Context, docID string, cv *Version, collectionID uint32, create bool) (value *revCacheValue) { |
| 424 | if docID == "" || cv == nil { |
| 425 | return nil |
| 426 | } |
| 427 | |
| 428 | key := IDandCV{DocID: docID, Source: cv.SourceID, Version: cv.Value, CollectionID: collectionID} |
| 429 | rc.lock.Lock() |
| 430 | defer rc.lock.Unlock() |
| 431 | if elem := rc.hlvCache[key]; elem != nil { |
| 432 | rc.lruList.MoveToFront(elem) |
| 433 | value = elem.Value.(*revCacheValue) |
| 434 | } else if create { |
| 435 | value = &revCacheValue{id: docID, cv: *cv, collectionID: collectionID} |
| 436 | value.canEvict.Store(false) |
| 437 | newElem := rc.lruList.PushFront(value) |
| 438 | rc.hlvCache[key] = newElem |
| 439 | rc.cacheNumItems.Add(1) |
| 440 | |
| 441 | // evict if over number capacity |
| 442 | numItemsRemoved, numBytesEvicted := rc._numberCapacityEviction() |
| 443 | if numBytesEvicted > 0 { |
| 444 | rc._decrRevCacheMemoryUsage(ctx, -numBytesEvicted) |
| 445 | } |
| 446 | |
| 447 | if numItemsRemoved > 0 { |
| 448 | rc.cacheNumItems.Add(-numItemsRemoved) |
| 449 | } |
| 450 | } |
| 451 | return |
| 452 | } |
| 453 | |
| 454 | // addToRevMapPostLoad will generate and entry in the Rev lookup map for a new document entering the cache |
| 455 | func (rc *LRURevisionCache) addToRevMapPostLoad(ctx context.Context, docID, revID string, cv *Version, collectionID uint32) { |
no test coverage detected