code: func (c *dbCache) needsFlush(tx *transaction) bool {
  	// A flush is needed when more time has elapsed than the configured
  	// flush interval.
  	if time.Since(c.lastFlush) > c.flushInterval {
  		return true
  	}
  
  	// A flush is needed when the size of the database cache exceeds the
  	// specified max cache size.  The total calculated size is multiplied by
  	// 1.5 here to account for additional memory consumption that will be
  	// needed during the flush as well as old nodes in the cache that are
  	// referenced by the snapshot used by the transaction.
  	snap := tx.snapshot
  	totalSize := snap.pendingKeys.Size() + snap.pendingRemove.Size()
  	totalSize = uint64(float64(totalSize) * 1.5)
  	return totalSize > c.maxSize
  }
docs: // needsFlush returns whether or not the database cache needs to be flushed to
  // persistent storage based on its current size, whether or not adding all of
  // the entries in the passed database transaction would cause it to exceed the
  // configured limit, and how much time has elapsed since the last time the cache
  // was flushed.
  //
  // This function MUST be called with the database write lock held.