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 names sort.StringSlice
  	for nameStr := range cache.names {
  		names = append(names, nameStr)
  	}
  	sort.Stable(names)
  
  	// Update or delete names.
  	for _, name := range names {
  		nameInfo := cache.names[name]
  		nameInfo.RLock()
  		if nameInfo.removed {
  			err := state.RemoveName(name)
  			if err != nil {
  				nameInfo.RUnlock()
  				return err
  			}
  		} else if nameInfo.updated {
  			err := state.UpdateName(nameInfo.entry)
  			if err != nil {
  				nameInfo.RUnlock()
  				return err
  			}
  		}
  		nameInfo.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