code: func (cache *Cache) Sync(state Writer) error {
  	cache.Lock()
  	defer cache.Unlock()
  	// Determine order for names
  	// note names may be of any length less than some limit
  	var hashes ProposalHashArray
  	for hash := range cache.proposals {
  		hashes = append(hashes, hash)
  	}
  	sort.Stable(hashes)
  
  	// Update or delete names.
  	for _, hash := range hashes {
  		proposalInfo := cache.proposals[hash]
  		proposalInfo.RLock()
  		if proposalInfo.removed {
  			err := state.RemoveProposal(hash[:])
  			if err != nil {
  				proposalInfo.RUnlock()
  				return err
  			}
  		} else if proposalInfo.updated {
  			err := state.UpdateProposal(hash[:], proposalInfo.ballot)
  			if err != nil {
  				proposalInfo.RUnlock()
  				return err
  			}
  		}
  		proposalInfo.RUnlock()
  	}
  	return nil
  }
docs: // Writes whatever is in the cache to the output Writer state. Does not flush the cache, to do that call Reset()
  // after Sync or use Flusth if your wish to use the output state as your next backend