// Set a key and value
977334
func (kv *KeyValue) Set(key, value string) error {
	if !kv.host.rawUTF8 {
		Encode(&value)
	}
	if _, err := kv.Get(key); err != nil {
		// Key does not exist, create it
		_, err = kv.host.db.Exec(fmt.Sprintf("INSERT INTO %s (attr) VALUES ('\"%s\"=>\"%s\"')", pq.QuoteIdentifier(kvPrefix+kv.table), escape(key), escape(value)))
		return err
	}
	// Key exists, update the value
	_, err := kv.host.db.Exec(fmt.Sprintf("UPDATE %s SET attr = attr || '\"%s\"=>\"%s\"' :: hstore", pq.QuoteIdentifier(kvPrefix+kv.table), escape(key), escape(value)))
	return err
}
598614
func (c *keyValueChanger) SetKey(key string) (string, error) {
	if c.err != nil {
		return "", c.err
	}
	if !c.node.container.duplicates {
		if c.node.hasDuplicateSibling(key) {
			return "", errors.New(ErrDuplicate, errorMessages)
		}
	}
	current := c.node.content.key().(string)
	c.node.content = keyValue{key, c.node.content.value()}
	return current, nil
}
531573
func (f *Flash) Set(key string, value interface{}) {
	if !f.changed {
		f.changed = true
	}
	if f.v == nil {
		f.v = make(flashData)
	}
	f.v[key] = []interface{}{value}
}
162378
func (m *SecureMap) Set(key, value interface{}) {

	if _, ok := m.data[key]; ok {
		return
	}

	m.lock.Lock()
	m.data[key] = value
	m.lock.Unlock()
}
542344
func (m Map) Set(key, value string) {
	m[key] = []string{value}
}
848408
func (r *Redis) Set(key string, value interface{}) error {
	return r.Client.Set(key, convertToBytes(value), 0).Err()
}
224371
func (c *Func) Set(key string, image *imageserver.Image, params imageserver.Params) error {
	return c.SetFunc(key, image, params)
}
981385
func (f *fileStorage) Set(key string, value []byte) error {
	file, err := f.fileForWrite(key)

	if err != nil {
		return err
	}

	defer file.Close()

	_, err = file.Write(value)
	return err
}
1295534
func (st *CookieSessionStore) Set(key, value interface{}) {
	st.lock.Lock()
	defer st.lock.Unlock()
	st.values[key] = value
}
1256132
func (s *Session) Set(key string, value interface{}) {
	if s.data == nil {
		s.data = make(Data)
	}
	s.changed = true
	s.data[key] = value
}
215972
func (smap *syncedMap) Set(key interface{}, val interface{}) {
	smap.Lock()
	defer smap.Unlock()

	smap.data[key] = val
}
802362
func (s *Settings) Set(key string, value interface{}) {
	s.core[key] = value
}
512061
func (s Session) Set(key string, value interface{}) error {
	if value == nil {
		s.Del(key)
		return nil
	}

	s[key] = value
	return nil
}
618726
func (v *Var) SetKey(value string) {
	// src := []byte(value)
	// regex := regexp.MustCompile("[0-9A-Za-z]+")
	// chunks := regex.FindAll(src, -1)
	// for i, val := range chunks {
	//
	// }
	v.Key = strings.ToUpper(value)
}
1298680
func (app *App) Set(key, val interface{}) *App {
	if k, ok := key.(appSetting); ok {
		switch key {
		case SetBodyParser:
			if bodyParser, ok := val.(BodyParser); !ok {
				panic(Err.WithMsg("SetBodyParser setting must implemented `gear.BodyParser` interface"))
			} else {
				app.bodyParser = bodyParser
			}
		case SetURLParser:
			if urlParser, ok := val.(URLParser); !ok {
				panic(Err.WithMsg("SetURLParser setting must implemented `gear.URLParser` interface"))
			} else {
				app.urlParser = urlParser
			}
		case SetCompress:
			if compress, ok := val.(Compressible); !ok {
				panic(Err.WithMsg("SetCompress setting must implemented `gear.Compressible` interface"))
			} else {
				app.compress = compress
			}
		case SetKeys:
			if keys, ok := val.([]string); !ok {
				panic(Err.WithMsg("SetKeys setting must be `[]string`"))
			} else {
				app.keys = keys
			}
		case SetLogger:
			if logger, ok := val.(*log.Logger); !ok {
				panic(Err.WithMsg("SetLogger setting must be `*log.Logger` instance"))
			} else {
				app.logger = logger
			}
		case SetParseError:
			if parseError, ok := val.(func(err error) HTTPError); !ok {
				panic(Err.WithMsg("SetParseError setting must be `func(err error) HTTPError`"))
			} else {
				app.parseError = parseError
			}
		case SetOnError:
			if onerror, ok := val.(func(ctx *Context, err HTTPError)); !ok {
				panic(Err.WithMsg("SetOnError setting must be `func(ctx *Context, err HTTPError)`"))
			} else {
				app.onerror = onerror
			}
		case SetSender:
			if sender, ok := val.(Sender); !ok {
				panic(Err.WithMsg("SetSender setting must implemented `gear.Sender` interface"))
			} else {
				app.sender = sender
			}
		case SetRenderer:
			if renderer, ok := val.(Renderer); !ok {
				panic(Err.WithMsg("SetRenderer setting must implemented `gear.Renderer` interface"))
			} else {
				app.renderer = renderer
			}
		case SetTimeout:
			if timeout, ok := val.(time.Duration); !ok {
				panic(Err.WithMsg("SetTimeout setting must be `time.Duration` instance"))
			} else {
				app.timeout = timeout
			}
		case SetWithContext:
			if withContext, ok := val.(func(*http.Request) context.Context); !ok {
				panic(Err.WithMsg("SetWithContext setting must be `func(*http.Request) context.Context`"))
			} else {
				app.withContext = withContext
			}
		case SetEnv:
			if _, ok := val.(string); !ok {
				panic(Err.WithMsg("SetEnv setting must be `string`"))
			}
		case SetServerName:
			if name, ok := val.(string); !ok {
				panic(Err.WithMsg("SetServerName setting must be `string`"))
			} else {
				app.serverName = name
			}
		case SetTrustedProxy:
			if _, ok := val.(bool); !ok {
				panic(Err.WithMsg("SetTrustedProxy setting must be `bool`"))
			}
		}
		app.settings[k] = val
		return app
	}
	app.settings[key] = val
	return app
}
1369810
func (c *Cache) Set(key string, value interface{}, size int64) {
	c.Lock()
	defer c.Unlock()

	var it *Item
	elem, ok := c.m[key]
	if ok {
		// Element exists, push it to front,
		// and then update value etc.
		it = elem.Value.(*Item)
		c.size -= it.Size
		c.l.MoveToFront(elem)
	} else {
		// Insert new element.
		it = &Item{Key: key}
		elem = c.l.PushFront(it)
		c.m[key] = elem
	}
	// Set or update item content.
	it.Value = value
	it.Size = size
	if it.Size < 0 {
		panic("cache: value has negative size")
	}
	it.ModTime = time.Now()
	it.AccessTime = it.ModTime

	// Update cache size.
	if it.Size >= math.MaxInt64-c.size {
		panic("cache: value size is too big")
	}
	c.size += it.Size

	c.enforceCapacity()
}
912499
func (d *ResourceData) Set(key string, value interface{}) error {
	d.once.Do(d.init)

	// If the value is a pointer to a non-struct, get its value and
	// use that. This allows Set to take a pointer to primitives to
	// simplify the interface.
	reflectVal := reflect.ValueOf(value)
	if reflectVal.Kind() == reflect.Ptr {
		if reflectVal.IsNil() {
			// If the pointer is nil, then the value is just nil
			value = nil
		} else {
			// Otherwise, we dereference the pointer as long as its not
			// a pointer to a struct, since struct pointers are allowed.
			reflectVal = reflect.Indirect(reflectVal)
			if reflectVal.Kind() != reflect.Struct {
				value = reflectVal.Interface()
			}
		}
	}

	err := d.setWriter.WriteField(strings.Split(key, "."), value)
	if err != nil && d.panicOnError {
		panic(err)
	}
	return err
}