MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / Put

Method Put

db/revision_cache_lru.go:314–333  ·  view source on GitHub ↗

Adds a revision to the cache.

(ctx context.Context, docRev DocumentRevision, collectionID uint32)

Source from the content-addressed store, hash-verified

312
313// Adds a revision to the cache.
314func (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.
336func (rc *LRURevisionCache) Upsert(ctx context.Context, docRev DocumentRevision, collectionID uint32) {

Calls 6

getValueByCVMethod · 0.95
addToRevMapPostLoadMethod · 0.95
CalculateBytesMethod · 0.80
storeMethod · 0.80