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

Method AddLateSequence

db/channel_cache_single.go:789–805  ·  view source on GitHub ↗

Receive new late sequence

(change *LogEntry)

Source from the content-addressed store, hash-verified

787
788// Receive new late sequence
789func (c *singleChannelCacheImpl) AddLateSequence(change *LogEntry) {
790 // Add to lateLogs.
791 lateEntry := &lateLogEntry{
792 logEntry: change,
793 arrived: time.Now(),
794 listenerCount: 0,
795 }
796 c.lateLogLock.Lock()
797 c.lateLogs = append(c.lateLogs, lateEntry)
798 c.lastLateSequence = change.Sequence
799 // Currently we're only purging on add. Could also consider a timed purge to handle the case
800 // where all the listeners get caught up, but there aren't any subsequent late entries. Not
801 // a high priority, as the memory overhead for the late entries should be trivial, and probably
802 // doesn't merit
803 c._purgeLateLogEntries()
804 c.lateLogLock.Unlock()
805}
806
807// Purge entries from the beginning of the list having no active listeners. Any newly connecting clients
808// will get these entries directly from the cache. Always maintain

Calls 3

_purgeLateLogEntriesMethod · 0.95
LockMethod · 0.45
UnlockMethod · 0.45