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

Method incrRevCacheMemoryUsage

db/revision_cache_lru.go:970–982  ·  view source on GitHub ↗

incrRevCacheMemoryUsage atomically increases overall memory usage for cache and the actual rev cache objects usage. You do not need to hold rev cache lock when using this function

(ctx context.Context, bytesCount int64)

Source from the content-addressed store, hash-verified

968// incrRevCacheMemoryUsage atomically increases overall memory usage for cache and the actual rev cache objects usage.
969// You do not need to hold rev cache lock when using this function
970func (rc *LRURevisionCache) incrRevCacheMemoryUsage(ctx context.Context, bytesCount int64) {
971 // We need to keep track of the current LRURevisionCache memory usage AND the overall usage of the cache. We need
972 // overall memory usage for the stat added to show rev cache usage plus we need the current rev cache capacity of the
973 // LRURevisionCache object for sharding the rev cache. This way we can perform eviction on per shard basis much like
974 // we do with the number of items capacity eviction
975 if bytesCount < 0 {
976 // function is for incrementing memory usage, so return if decrementing
977 base.AssertfCtx(ctx, "Attempting to decrement memory stats with inside increment function, should use _decrRevCacheMemoryUsage instead whilst holding rev cache lock")
978 return
979 }
980 rc.currMemoryUsage.Add(bytesCount)
981 rc.cacheMemoryBytesStat.Add(bytesCount)
982}
983
984func (rc *LRURevisionCache) _findEvictionValue() *revCacheValue {
985 evictionCandidate := rc.lruList.Back()

Callers 5

getFromCacheByRevMethod · 0.95
getFromCacheByCVMethod · 0.95
GetActiveMethod · 0.95
PutMethod · 0.95
UpsertMethod · 0.95

Calls 2

AssertfCtxFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected