code: func (e *Engine) compactCache() {
  	t := time.NewTicker(time.Second)
  	defer t.Stop()
  	for {
  		e.mu.RLock()
  		quit := e.snapDone
  		e.mu.RUnlock()
  
  		select {
  		case <-quit:
  			return
  
  		case <-t.C:
  			e.Cache.UpdateAge()
  			if e.ShouldCompactCache(time.Now()) {
  				start := time.Now()
  				e.traceLogger.Info("Compacting cache", zap.String("path", e.path))
  				err := e.WriteSnapshot()
  				if err != nil && err != errCompactionsDisabled {
  					e.logger.Info("Error writing snapshot", zap.Error(err))
  				}
  				e.compactionTracker.SnapshotAttempted(err == nil || err == errCompactionsDisabled, time.Since(start))
  			}
  		}
  	}
  }
docs: // compactCache continually checks if the WAL cache should be written to disk.