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

Method _getCachedChanges

db/channel_cache_single.go:339–366  ·  view source on GitHub ↗
(sinceSeq uint64, limit int)

Source from the content-addressed store, hash-verified

337}
338
339func (c *singleChannelCacheImpl) _getCachedChanges(sinceSeq uint64, limit int) (validFrom uint64, result []*LogEntry) {
340 // Find the first entry in the log to return:
341 log := c.logs
342 if len(log) == 0 {
343 validFrom = c.validFrom
344 return // Return nil if nothing is cached
345 }
346 var start int
347 for start = len(log) - 1; start >= 0 && log[start].Sequence > sinceSeq; start-- {
348 }
349 start++
350
351 if start > 0 {
352 validFrom = log[start-1].Sequence + 1
353 } else {
354 validFrom = c.validFrom
355 }
356
357 n := len(log) - start
358
359 if limit > 0 && n > limit {
360 n = limit
361 }
362
363 result = make([]*LogEntry, n)
364 copy(result[0:], log[start:])
365 return
366}
367
368// Top-level method to get all the changes in a channel since the sequence 'since'.
369// If the cache doesn't go back far enough, the view will be queried.

Callers 1

GetCachedChangesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected