// Add stores a key value par in the cache. If the key was already present,
// it is moved to the front
193780
func (lru *LRUCache) Add(key, val interface{}) {
	lru.lock.Lock()
	defer lru.lock.Unlock()

	if element, ok := lru.mapping[key]; ok {
		element.Value.(*pair).val = val
		lru.order.MoveToFront(element)
		return
	}

	lru.mapping[key] = lru.order.PushFront(&pair{key, val})

	for lru.order.Len() > lru.capacity {
		element := lru.order.Back()
		lru.order.Remove(element)
		delete(lru.mapping, element.Value.(*pair).key)
	}
}
1346718
func (c *lruEvictedCache) Add(key Measurable, data Measurable) {
	memoized := memoizedMeasurable{m: data}
	keySize := key.Size()
	if keySize+memoized.Size() > c.maxBytes {
		return
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	if v, ok := c.data.Get(lru.Key(key)); ok {
		if m, ok := v.(memoizedMeasurable); ok {
			c.cachedBytes -= keySize + m.Size()
		}
	}
	c.cachedBytes += keySize + memoized.Size()
	for c.cachedBytes > c.maxBytes {
		c.data.RemoveOldest()
	}
	c.data.Add(lru.Key(key), memoized)
}
474568
func (c *Cache) Put(ctx context.Context, key storage.CacheKey, val []byte, exp time.Duration) {
	c.mu.Lock()
	defer c.mu.Unlock()

	if c.cacheMap == nil {
		c.cacheMap = make(map[storage.CacheKey][]byte)
	}

	c.cacheMap[key] = val
}
97405
func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.cache.Add(c.composeKey(uid, name), reasonItem{reason, message})
}
840897
func (s *RedisSetStore) Add(key string, values ...string) error {
	if !strings.HasPrefix(key, s.prefix) {
		key = s.prefix + key
	}
	valuesI := make([]interface{}, len(values))
	for i, v := range values {
		valuesI[i] = v
	}
	return s.client.SAdd(key, valuesI...).Err()
}
32559
func (kp *Keypairs) Add(keypairs ...ClaimedKeyPair) error {
	for _, k := range keypairs {
		kp.idIndex[*k.PublicKey.ID] = k

		orgID := *k.PublicKey.Body.OrgID
		_, ok := kp.keypairs[orgID]
		if !ok {
			kp.keypairs[orgID] = []ClaimedKeyPair{k}
			continue
		}

		kp.keypairs[orgID] = append(kp.keypairs[orgID], k)
	}

	return nil
}
619178
func (c *Client) Add(key, val string, flags, exp uint32) (cas uint64, err error) {
	// Variants: Add [Q]
	return c.setGeneric(opAdd, key, val, 0, flags, exp)
}
1159622
func (c *keyValueChanger) Add(k string, v interface{}) error {
	if c.err != nil {
		return c.err
	}
	_, err := c.node.addChild(keyValue{k, v})
	return err
}
455315
func (as *accountSet) add(addr common.Address) {
	as.accounts[addr] = struct{}{}
	as.cache = nil
}
68652
func (bsh *BufferedServerHeader) Add(key string, value string) {
	if bsh.released {
		bsh.original.Set(key, value)
	} else {
		old := []string{}
		if v, found := bsh.headerMap[key]; found {
			old = v
		}
		bsh.headerMap[key] = append(old, value)
	}
}
1236486
func (c *TwoQueueCache) Add(key, value interface{}) {
	c.lock.Lock()
	defer c.lock.Unlock()

	// Check if the value is frequently used already,
	// and just update the value
	if c.frequent.Contains(key) {
		c.frequent.Add(key, value)
		return
	}

	// Check if the value is recently used, and promote
	// the value into the frequent list
	if c.recent.Contains(key) {
		c.recent.Remove(key)
		c.frequent.Add(key, value)
		return
	}

	// If the value was recently evicted, add it to the
	// frequently used list
	if c.recentEvict.Contains(key) {
		c.ensureSpace(true)
		c.recentEvict.Remove(key)
		c.frequent.Add(key, value)
		return
	}

	// Add to the recently seen list
	c.ensureSpace(false)
	c.recent.Add(key, value)
	return
}
221782
func (s *SourcesStore) Add(ctx context.Context, src chronograf.Source) (chronograf.Source, error) {
	return s.AddF(ctx, src)
}
1250801
func (s *SyncedSet) Add(datas ...interface{}) {
	s.Lock()
	defer s.Unlock()
	for _, data := range datas {
		s.set[data] = true
	}
}
494463
func (b *Builder) Add(args ...string) error {
	for _, a := range args {
		if err := b.add(a); err != nil {
			return errwrap.Wrapf(fmt.Sprintf("invalid key/value pair %q: {{err}}", a), err)
		}
	}

	return nil
}
1251282
func (c *Cache) Add(index uint64, obj interface{}) bool {
	return c.getShard(index).add(index, obj)
}
974112
func (c *randomEvictedCache) Add(key Measurable, data Measurable) {
	memoizedKey := memoizedMeasurable{m: key}
	memoizedData := memoizedMeasurable{m: data}
	increase := c.entrySize(memoizedKey, memoizedData)
	if increase > c.maxBytes {
		return
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	if v, ok := c.data[key]; ok {
		decrease := c.entrySize(memoizedKey, v)
		c.cachedBytes -= decrease
	}
	c.cachedBytes += increase
	for c.cachedBytes > c.maxBytes {
		c.evictOneLocked()
	}
	c.data[key] = memoizedData
	c.keys = append(c.keys, memoizedKey)
}
406874
func (c *ObjectCache) Add(key string, obj interface{}) error {
	err := c.cache.Add(objectEntry{key: key, obj: obj})
	if err != nil {
		return err
	}
	return nil
}