addToRevMapPostLoad will generate and entry in the Rev lookup map for a new document entering the cache
(ctx context.Context, docID, revID string, cv *Version, collectionID uint32)
| 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) { |
| 456 | if revID == "" { |
| 457 | // no revID to map to, exit early |
| 458 | return |
| 459 | } |
| 460 | legacyKey := IDAndRev{DocID: docID, RevID: revID, CollectionID: collectionID} |
| 461 | key := IDandCV{DocID: docID, Source: cv.SourceID, Version: cv.Value, CollectionID: collectionID} |
| 462 | |
| 463 | rc.lock.Lock() |
| 464 | defer rc.lock.Unlock() |
| 465 | // check for existing value in rev cache map (due to concurrent fetch by rev ID) |
| 466 | cvElem, cvFound := rc.hlvCache[key] |
| 467 | _, revFound := rc.cache[legacyKey] |
| 468 | if !cvFound { |
| 469 | // its possible the element has been evicted if we don't find the element above (high churn on rev cache) |
| 470 | // need to return doc revision to caller still but no need repopulate the cache |
| 471 | return |
| 472 | } |
| 473 | // Check if another goroutine has already updated the rev map |
| 474 | if !revFound { |
| 475 | // if not found we need to add the element to the rev lookup (for PUT code path) |
| 476 | rc.cache[legacyKey] = cvElem |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | // addToHLVMapPostLoad will generate and entry in the CV lookup map for a new document entering the cache |
| 481 | func (rc *LRURevisionCache) addToHLVMapPostLoad(ctx context.Context, docID, revID string, cv *Version, collectionID uint32) { |
no test coverage detected