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

Function newChannelCacheWithOptions

db/channel_cache_single.go:137–161  ·  view source on GitHub ↗
(ctx context.Context, queryHandler ChannelQueryHandler, channel channels.ID, validFrom uint64, options ChannelCacheOptions, cacheStats *base.CacheStats)

Source from the content-addressed store, hash-verified

135}
136
137func newChannelCacheWithOptions(ctx context.Context, queryHandler ChannelQueryHandler, channel channels.ID, validFrom uint64, options ChannelCacheOptions, cacheStats *base.CacheStats) *singleChannelCacheImpl {
138 cache := newSingleChannelCache(queryHandler, channel, validFrom, cacheStats)
139
140 // Update cache options when present
141 if options.ChannelCacheMinLength > 0 {
142 cache.options.ChannelCacheMinLength = options.ChannelCacheMinLength
143 }
144
145 if options.ChannelCacheMaxLength > 0 {
146 cache.options.ChannelCacheMaxLength = options.ChannelCacheMaxLength
147 }
148
149 if options.ChannelCacheAge > 0 {
150 cache.options.ChannelCacheAge = options.ChannelCacheAge
151 }
152
153 if options.MaxNumChannels > 0 {
154 cache.options.MaxNumChannels = options.MaxNumChannels
155 }
156
157 base.DebugfCtx(ctx, base.KeyCache, "Initialized cache for channel %q with min:%v max:%v age:%v, validFrom: %d",
158 base.UD(cache.channelID), cache.options.ChannelCacheMinLength, cache.options.ChannelCacheMaxLength, cache.options.ChannelCacheAge, validFrom)
159
160 return cache
161}
162
163type ChannelCacheOptions struct {
164 ChannelCacheMinLength int // Keep at least this many entries in each per-channel cache

Callers 1

addChannelCacheMethod · 0.85

Calls 3

DebugfCtxFunction · 0.92
UDFunction · 0.92
newSingleChannelCacheFunction · 0.85

Tested by

no test coverage detected