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

Method store

db/revision_cache_lru.go:807–824  ·  view source on GitHub ↗

Stores a body etc. into a revCacheValue if there isn't one already.

(docRev DocumentRevision)

Source from the content-addressed store, hash-verified

805
806// Stores a body etc. into a revCacheValue if there isn't one already.
807func (value *revCacheValue) store(docRev DocumentRevision) {
808 value.lock.Lock()
809 defer value.lock.Unlock()
810 if value.bodyBytes == nil {
811 value.revID = docRev.RevID
812 value.id = docRev.DocID
813 value.bodyBytes = docRev.BodyBytes
814 value.history = docRev.History
815 value.channels = docRev.Channels
816 value.expiry = docRev.Expiry
817 value.attachments = docRev.Attachments.ShallowCopy() // Don't store attachments the caller might later mutate
818 value.deleted = docRev.Deleted
819 value.err = nil
820 value.itemBytes.Store(docRev.MemoryBytes)
821 value.hlvHistory = docRev.HlvHistory
822 }
823 value.canEvict.Store(true) // now we have stored the doc revision in the cache, we can allow eviction
824}
825
826func (value *revCacheValue) updateDelta(toDelta RevisionDelta) (diffInBytes int64) {
827 value.lock.Lock()

Callers 2

PutMethod · 0.80
UpsertMethod · 0.80

Calls 4

StoreMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
ShallowCopyMethod · 0.45

Tested by

no test coverage detected