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

Method _decrRevCacheMemoryUsage

db/revision_cache_lru.go:954–966  ·  view source on GitHub ↗

_decrRevCacheMemoryUsage atomically decreases overall memory usage for cache and the actual rev cache objects usage. You should be holding rev cache lock in using this function to avoid eviction processes over evicting items

(ctx context.Context, bytesCount int64)

Source from the content-addressed store, hash-verified

952// _decrRevCacheMemoryUsage atomically decreases overall memory usage for cache and the actual rev cache objects usage.
953// You should be holding rev cache lock in using this function to avoid eviction processes over evicting items
954func (rc *LRURevisionCache) _decrRevCacheMemoryUsage(ctx context.Context, bytesCount int64) {
955 // We need to keep track of the current LRURevisionCache memory usage AND the overall usage of the cache. We need
956 // overall memory usage for the stat added to show rev cache usage plus we need the current rev cache capacity of the
957 // LRURevisionCache object for sharding the rev cache. This way we can perform eviction on per shard basis much like
958 // we do with the number of items capacity eviction
959 if bytesCount > 0 {
960 // function is for decrementing memory usage, so return if incrementing
961 base.AssertfCtx(ctx, "Attempting to increment memory stats with inside decrement function, should use incrRevCacheMemoryUsage instead")
962 return
963 }
964 rc.currMemoryUsage.Add(bytesCount)
965 rc.cacheMemoryBytesStat.Add(bytesCount)
966}
967
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

Callers 6

upsertDocToCacheMethod · 0.95
getValueMethod · 0.95
getValueByCVMethod · 0.95
removeFromCacheByCVMethod · 0.95
removeFromCacheByRevMethod · 0.95

Calls 2

AssertfCtxFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected