// Set first tranforms the key, and the value if one or both of the KeyFunc and
// ValueFunc funcs aren't nil. It then calls the underlying handler this the
// (optionally) transformed key and value.
355690
func (h *applyHandler) Set(key string, value interface{}, args ...interface{}) error {
	var err error
	if h.keyFunc != nil {
		key, err = h.keyFunc(key)
		if err != nil {
			return err
		}
	}

	if h.valueFunc != nil {
		value, err = h.valueFunc(value)
		if err != nil {
			return err
		}
	}
	return h.handler.Set(key, value, args...)
}
286431
func (c *Strings) Set(value string) error {
	*c = append(*c, value)
	return nil
}
512061
func (s Session) Set(key string, value interface{}) error {
	if value == nil {
		s.Del(key)
		return nil
	}

	s[key] = value
	return nil
}
121298
func (v Values) Set(key, value string) {
	v[key] = []string{value}
}
5950
func (m *Map) Set(k KeyType, v ValueType) {
	m.set(k, v, mapKeyOptions{
		copyKey:     true,
		finalizeKey: m.finalize != nil,
	})
}
707878
func (mBatch *goLevelDBBatch) Set(key, value []byte) {
	mBatch.batch.Put(key, value)
}
252249
func (d *CodeGenOptions) Set(optFns ...func(*CodeGenOptions)) {
	for _, fn := range optFns {
		fn(d)
	}
}
726861
func (c *TwoTier) Set(key string, value []byte) {
	c.second.Set(key, value)
	c.first.Delete(key)
}
230343
func (h *envHandler) Set(key string, value interface{}, args ...interface{}) error {
	if len(args) != 0 {
		return cfg.ErrArgsNotSupported
	}
	sval, err := cfg.ToString(value)
	if err != nil {
		return cfg.ErrBadType
	}

	err = os.Setenv(key, sval)
	if err != nil {
		return cfg.ErrKeyNotSet
	}

	return nil
}
167577
func (c *Client) Set(key, value string) error {
	key = strings.ToUpper(key)
	if value != "" {
		value = " " + value
	}
	val := "SET" + key + value + "\n"
	if _, err := c.in.Write([]byte(val)); err != nil {
		return err
	}
	line, _, _ := c.out.ReadLine()
	if string(line) != "OK" {
		return errors.Errorf("error: %s", line)
	}
	return nil
}
224371
func (c *Func) Set(key string, image *imageserver.Image, params imageserver.Params) error {
	return c.SetFunc(key, image, params)
}
832249
func (m *lockingMap) Set(key string, val interface{}) {
	m.keyLocker.Lock(key)
	defer m.keyLocker.Unlock(key)

	m.lock.Lock()
	defer m.lock.Unlock()

	m.data[key] = val
}
1251302
func (d *Data) Set(key string, value string) {
	d.Values.Set(key, value)
}
349636
func (s *Safe) Set(value interface{}) {
	s.lock.Lock()
	defer s.lock.Unlock()
	s.value = value
}
178962
func (i *Int) Set(value int) {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment = value
}
1361769
func (h *Handle) set(ordinal, start, end uint64, any bool, release bool, serial bool) (uint64, error) {
	var (
		bitPos  uint64
		bytePos uint64
		ret     uint64
		err     error
	)

	for {
		var store datastore.DataStore
		curr := uint64(0)
		h.Lock()
		store = h.store
		if store != nil {
			h.Unlock() // The lock is acquired in the GetObject
			if err := store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound {
				return ret, err
			}
			h.Lock() // Acquire the lock back
		}
		if serial {
			curr = h.curr
		}
		// Get position if available
		if release {
			bytePos, bitPos = ordinalToPos(ordinal)
		} else {
			if any {
				bytePos, bitPos, err = getAvailableFromCurrent(h.head, start, curr, end)
				ret = posToOrdinal(bytePos, bitPos)
				if err == nil {
					h.curr = ret + 1
				}
			} else {
				bytePos, bitPos, err = checkIfAvailable(h.head, ordinal)
				ret = ordinal
			}
		}
		if err != nil {
			h.Unlock()
			return ret, err
		}

		// Create a private copy of h and work on it
		nh := h.getCopy()

		nh.head = pushReservation(bytePos, bitPos, nh.head, release)
		if release {
			nh.unselected++
		} else {
			nh.unselected--
		}

		if h.store != nil {
			h.Unlock()
			// Attempt to write private copy to store
			if err := nh.writeToStore(); err != nil {
				if _, ok := err.(types.RetryError); !ok {
					return ret, fmt.Errorf("internal failure while setting the bit: %v", err)
				}
				// Retry
				continue
			}
			h.Lock()
		}

		// Previous atomic push was successful. Save private copy to local copy
		h.unselected = nh.unselected
		h.head = nh.head
		h.dbExists = nh.dbExists
		h.dbIndex = nh.dbIndex
		h.Unlock()
		return ret, nil
	}
}
1301299
func (kv *KeyValSlice) Set(v string) error {
	if len(*kv) == 0 {
		*kv = make([]map[string]string, 0)
	}
	var i KeyVal
	if err := i.Set(v); err != nil {
		return trace.Wrap(err)
	}
	*kv = append(*kv, i)
	return nil
}