// Set sets a key-value to the redis store.
// The expiration is setted by the MaxAgeSeconds.
772644
func (r *Service) Set(key string, value interface{}, secondsLifetime int64) (err error) {
	c := r.pool.Get()
	defer c.Close()
	if c.Err() != nil {
		return c.Err()
	}

	// if has expiration, then use the "EX" to delete the key automatically.
	if secondsLifetime > 0 {
		_, err = c.Do("SETEX", r.Config.Prefix+key, secondsLifetime, value)
	} else {
		_, err = c.Do("SET", r.Config.Prefix+key, value)
	}

	return
}
1259447
func (d *DiskStorer) Set(key, value string) error {
	if !validKey(key) {
		return errNoSession{}
	}

	filePath := path.Join(d.folderPath, key)

	d.mut.Lock()
	defer d.mut.Unlock()

	return ioutil.WriteFile(filePath, []byte(value), 0600)
}
973090
func (c *Cache) Set(key string, value interface{}, duration time.Duration) {
	c.set(key, value, duration)
}
700458
func (r *RedisStorer) Set(key, value string) error {
	return r.client.Set(key, value, r.maxAge).Err()
}
134685
func (mem *Memcache) Set(key string, val interface{}, timeout time.Duration) (err error) {
	var data []byte
	if data, err = json.Marshal(val); err != nil {
		return err
	}

	item := &memcache.Item{Key: key, Value: data, Expiration: int32(timeout / time.Second)}
	return mem.conn.Set(item)
}
433592
func (s *MemStore) Set(key, val interface{}) error {
	s.lock.Lock()
	defer s.lock.Unlock()

	s.data[key] = val
	return nil
}
531540
func (c *xContext) Set(key string, val interface{}) {
	c.store.Set(key, val)
}
1310839
func (p *SessionStore) Set(key string, value interface{}) error {
	p.Lock()
	defer p.Unlock()
	p.values[key] = value
	return nil
}
1190514
func (s *storeImpl) Set(key string, val interface{}) {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	s.objects[key] = object{contents: val}
}
377059
func (c *InMemoryCache) Set(_ context.Context, key Key, value Thunk) {
	c.mu.Lock()
	c.items[key.String()] = value
	c.mu.Unlock()
}
884124
func (db *Database) Set(sid string, lifetime sessions.LifeTime, key string, value interface{}, immutable bool) {
	valueBytes, err := sessions.DefaultTranscoder.Marshal(value)
	if err != nil {
		golog.Debug(err)
		return
	}

	err = db.Service.Update(func(tx *bolt.Tx) error {
		b := db.getBucketForSession(tx, sid)
		if b == nil {
			return nil
		}

		// Author's notes:
		// expiration is handlded by the session manager for the whole session, so the `db.Destroy` will be called when and if needed.
		// Therefore we don't have to implement a TTL here, but we need a `db.Cleanup`, as we did previously, method to delete any expired if server restarted
		// (badger does not need a `Cleanup` because we set the TTL based on the lifetime.DurationUntilExpiration()).
		return b.Put(makeKey(key), valueBytes)
	})

	if err != nil {
		golog.Debug(err)
	}
}
61559
func (m *MongoCache) Set(key string, value interface{}) error {
	return m.set(key, m.TTL, value)
}
664353
func (reg *HostExpirationRegistry) Set(hostid string, expires int64) {
	reg.Lock()
	defer reg.Unlock()
	reg.registry[hostid] = expires
}
570570
func (i RedisClientWrapper) Set(key string, val []byte) error {
	err := i.Client.Set(key, val, 0).Err()
	return err
}
848408
func (r *Redis) Set(key string, value interface{}) error {
	return r.Client.Set(key, convertToBytes(value), 0).Err()
}
632946
func (c *LruCache) Set(key string, value []byte) {
	c.mu.Lock()

	expires := int64(0)
	if c.MaxAge > 0 {
		expires = time.Now().Unix() + c.MaxAge
	}

	if le, ok := c.cache[key]; ok {
		c.lru.MoveToBack(le)
		e := le.Value.(*entry)
		c.size += int64(len(value)) - int64(len(e.value))
		e.value = value
		e.expires = expires
	} else {
		e := &entry{key: key, value: value, expires: expires}
		c.cache[key] = c.lru.PushBack(e)
		c.size += e.size()
	}

	c.maybeDeleteOldest()

	c.mu.Unlock()
}
523280
func (_m *HostExpirationRegistryInterface) Set(_a0 string, _a1 int64) {
	_m.Called(_a0, _a1)
}