Adds a revision to the cache.
(ctx context.Context, docRev DocumentRevision, collectionID uint32)
| 312 | |
| 313 | // Adds a revision to the cache. |
| 314 | func (rc *LRURevisionCache) Put(ctx context.Context, docRev DocumentRevision, collectionID uint32) { |
| 315 | if docRev.History == nil { |
| 316 | // TODO: CBG-1948 |
| 317 | panic("Missing history for RevisionCache.Put") |
| 318 | } |
| 319 | |
| 320 | // doc should always have a cv present in a PUT operation on the cache (update HLV is called before hand in doc update process) |
| 321 | // thus we can call getValueByCV directly the update the rev lookup post this |
| 322 | value := rc.getValueByCV(ctx, docRev.DocID, docRev.CV, collectionID, true) |
| 323 | // increment incoming bytes |
| 324 | docRev.CalculateBytes() |
| 325 | rc.incrRevCacheMemoryUsage(ctx, docRev.MemoryBytes) |
| 326 | value.store(docRev) |
| 327 | |
| 328 | // add new doc version to the rev id lookup map |
| 329 | rc.addToRevMapPostLoad(ctx, docRev.DocID, docRev.RevID, docRev.CV, collectionID) |
| 330 | |
| 331 | // check for rev cache memory based eviction |
| 332 | rc.revCacheMemoryBasedEviction(ctx) |
| 333 | } |
| 334 | |
| 335 | // Upsert a revision in the cache. |
| 336 | func (rc *LRURevisionCache) Upsert(ctx context.Context, docRev DocumentRevision, collectionID uint32) { |