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

Method Clear

db/change_cache.go:240–260  ·  view source on GitHub ↗

Empty out all channel caches.

(ctx context.Context)

Source from the content-addressed store, hash-verified

238
239// Empty out all channel caches.
240func (c *changeCache) Clear(ctx context.Context) error {
241 c.lock.Lock()
242 defer c.lock.Unlock()
243
244 // Reset initialSequence so that any new channel caches have their validFrom set to the current last sequence
245 // the point at which the change cache was initialized / re-initialized.
246 // No need to touch c.nextSequence here, because we don't want to touch the sequence buffering state.
247 var err error
248 c.initialSequence, err = c.db.LastSequence(ctx)
249 if err != nil {
250 return err
251 }
252
253 c.pendingLogs = nil
254 heap.Init(&c.pendingLogs)
255
256 c.initTime = time.Now()
257
258 c.channelCache.Clear()
259 return nil
260}
261
262// If set to false, DocChanged() becomes a no-op.
263func (c *changeCache) EnableChannelIndexing(enable bool) {

Callers

nothing calls this directly

Calls 5

InitMethod · 0.65
ClearMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
LastSequenceMethod · 0.45

Tested by

no test coverage detected