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

Function NewRevisionCache

db/revision_cache_interface.go:83–111  ·  view source on GitHub ↗

NewRevisionCache returns a RevisionCache implementation for the given config options.

(cacheOptions *RevisionCacheOptions, backingStores map[uint32]RevisionCacheBackingStore, cacheStats *base.CacheStats)

Source from the content-addressed store, hash-verified

81
82// NewRevisionCache returns a RevisionCache implementation for the given config options.
83func NewRevisionCache(cacheOptions *RevisionCacheOptions, backingStores map[uint32]RevisionCacheBackingStore, cacheStats *base.CacheStats) RevisionCache {
84
85 // If cacheOptions is not passed in, use defaults
86 if cacheOptions == nil {
87 cacheOptions = DefaultRevisionCacheOptions()
88 }
89
90 if cacheOptions.MaxItemCount == 0 {
91 bypassStat := cacheStats.RevisionCacheBypass
92 return NewBypassRevisionCache(backingStores, bypassStat)
93 }
94
95 cacheHitStat := cacheStats.RevisionCacheHits
96 cacheMissStat := cacheStats.RevisionCacheMisses
97 cacheNumItemsStat := cacheStats.RevisionCacheNumItems
98 cacheMemoryStat := cacheStats.RevisionCacheTotalMemory
99 if cacheNumItemsStat.Value() != 0 {
100 cacheNumItemsStat.Set(0)
101 }
102 if cacheMemoryStat.Value() != 0 {
103 cacheMemoryStat.Set(0)
104 }
105
106 if cacheOptions.ShardCount > 1 {
107 return NewShardedLRURevisionCache(cacheOptions, backingStores, cacheHitStat, cacheMissStat, cacheNumItemsStat, cacheMemoryStat)
108 }
109
110 return NewLRURevisionCache(cacheOptions, backingStores, cacheHitStat, cacheMissStat, cacheNumItemsStat, cacheMemoryStat)
111}
112
113type RevisionCacheOptions struct {
114 MaxItemCount uint32

Callers 2

NewDatabaseContextFunction · 0.85

Calls 6

NewBypassRevisionCacheFunction · 0.85
NewLRURevisionCacheFunction · 0.85
ValueMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected