// Add adds the provided key and value to the cache, evicting
// an old item if necessary.
430222
func (c *Cache) Add(key string, value interface{}) {
	if !c.nolock {
		c.mu.Lock()
		defer c.mu.Unlock()
	}

	// Already in cache?
	if ee, ok := c.cache[key]; ok {
		c.ll.MoveToFront(ee)
		ee.Value.(*entry).value = value
		return
	}

	// Add to cache if not present
	ele := c.ll.PushFront(&entry{key, value})
	c.cache[key] = ele

	if c.maxEntries > 0 && c.ll.Len() > c.maxEntries {
		c.removeOldest()
	}
}
1159881
func (a *AuditedHeadersConfig) add(ctx context.Context, header string, hmac bool) error {
	if header == "" {
		return fmt.Errorf("header value cannot be empty")
	}

	// Grab a write lock
	a.Lock()
	defer a.Unlock()

	if a.Headers == nil {
		a.Headers = make(map[string]*auditedHeaderSettings, 1)
	}

	a.Headers[strings.ToLower(header)] = &auditedHeaderSettings{hmac}
	entry, err := logical.StorageEntryJSON(auditedHeadersEntry, a.Headers)
	if err != nil {
		return errwrap.Wrapf("failed to persist audited headers config: {{err}}", err)
	}

	if err := a.view.Put(ctx, entry); err != nil {
		return errwrap.Wrapf("failed to persist audited headers config: {{err}}", err)
	}

	return nil
}
556060
func (c *ExpirationCache) Add(obj interface{}) error {
	key, err := c.keyFunc(obj)
	if err != nil {
		return KeyError{obj, err}
	}
	c.cacheStorage.Add(key, &timestampedEntry{obj, c.clock.Now()})
	return nil
}
211243
func (v *OrderedValues) Add(key, val []byte) {
	for i, j := range *v {
		if len(j) > 0 && bytes.Equal(j[0], key) {
			if len(val) > 0 {
				(*v)[i] = append((*v)[i], val)
			}
			return
		}
	}
	if len(val) == 0 {
		*v = append(*v, [][]byte{key})
	} else {
		*v = append(*v, [][]byte{key, val})
	}
}
455315
func (as *accountSet) add(addr common.Address) {
	as.accounts[addr] = struct{}{}
	as.cache = nil
}
1013774
func (v Values) Add(key, value string) {
	v[key] = append(v[key], value)
}
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)
}
1356932
func (c *ExpirationCache) Add(obj interface{}) error {
	key, err := c.keyFunc(obj)
	if err != nil {
		return KeyError{obj, err}
	}
	c.expirationLock.Lock()
	defer c.expirationLock.Unlock()

	c.cacheStorage.Add(key, &TimestampedEntry{obj, c.clock.Now()})
	return nil
}
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})
}
945081
func (c *pubKeyCache) add(candidate cachedPubKey) {
	if len(c.keys) < maxCachedPubKeys {
		c.keys = append(c.keys, candidate)
	}
}
1129095
func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.cache.Add(key, &cacheEntry{value, c.clock.Now().Add(ttl)})
}
948050
func (c *Cache) Put(key string, item *Item) (err error) {
	in := struct {
		Value     interface{} `json:"value"`
		ExpiresIn int         `json:"expires_in,omitempty"`
		Replace   bool        `json:"replace,omitempty"`
		Add       bool        `json:"add,omitempty"`
	}{
		Value:     item.Value,
		ExpiresIn: int(item.Expiration.Seconds()),
		Replace:   item.Replace,
		Add:       item.Add,
	}

	return c.caches(c.Name, "items", key).Req("PUT", &in, nil)
}
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
}
450929
func (al *assetLru) Add(key int64, value *assetCache) {
	// Already in cache?
	if ee, ok := al.cache[key]; ok {
		al.ll.MoveToFront(ee)
		ee.Value.value = value
		return
	}

	// Add to cache if not present
	ele := al.ll.PushFront(&assetLruListEntry{key, value})
	al.cache[key] = ele

	if al.ll.Len() > al.maxEntries {
		al.removeOldest()
	}
}
1113371
func (c *DbClient) Add(path string, entry *decoder.FileDataEntry) {
	c.Lock()
	defer c.Unlock()

	if entry == nil {
		return
	}

	fileData, ok := c.db[path]
	if ok {
		value, ok := fileData[entry.Key]
		if ok {
			if !bytes.Equal(value.data, entry.Value) {
				rev := value.rev + 1
				fileData[entry.Key] = &dbEntry{entry.Value, rev}
			}
		} else {
			fileData[entry.Key] = &dbEntry{entry.Value, initialRev}
		}
	} else {
		fileData = map[string]*dbEntry{entry.Key: {entry.Value, initialRev}}
	}

	c.db[path] = fileData
}
451659
func (b *Base) Add(key string, value interface{}) Serializer {
	return b.AddIf(alwaysTrue, key, value)
}
384529
func (c *UIDCache) Add(uid types.UID) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.cache.Add(uid, nil)
}