/*
Add the specified members to the set stored at key. Specified members that are
already a member of this set are ignored. If key does not exist, a new set is
created before adding the specified members.

http://redis.io/commands/sadd
*/
509897
func (c *Client) SAdd(key string, member ...interface{}) (int64, error) {
	var ret int64

	args := make([][]byte, len(member)+2)
	args[0] = []byte("SADD")
	args[1] = []byte(key)

	for i := range member {
		args[2+i] = to.Bytes(member[i])
	}

	err := c.command(&ret, args...)

	return ret, err
}
323770
func (s *DistinctNetSet) Add(ip net.IP) bool {
	key := s.key(ip)
	n := s.members[string(key)]
	if n < s.Limit {
		s.members[string(key)] = n + 1
		return true
	}
	return false
}
284324
func (db *RedisDB) ssetRem(key, member string) bool {
	ss := db.sortedsetKeys[key]
	_, ok := ss[member]
	delete(ss, member)
	if len(ss) == 0 {
		// Delete key on removal of last member
		db.del(key, true)
	}
	return ok
}
946690
func (s *Map) Add(errType string, id string) {
	if strings.ToLower(errType) == OK {
		s.Valid++
	} else {
		if s.Invalid == nil {
			s.Invalid = make(map[string][]string)
		}
		s.Invalid[errType] = append(s.Invalid[errType], id)
	}
}
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)
	}
}
15661
func (p *Pool) addToPoolSet() error {
	conn := redisPool.Get()
	defer conn.Close()
	p.RLock()
	thisId := p.id
	p.RUnlock()
	if _, err := conn.Do("SADD", Keys.ActivePools, thisId); err != nil {
		return err
	}
	return nil
}
262806
func (s *Set) Add(item interface{}) {
	s.lock.Lock()
	defer s.lock.Unlock()
	s.items[item] = struct{}{}
}
1160381
func (s *Set) Add(value interface{}) bool {
	// Check existence
	found := s.Has(value)

	// Lock set for write
	s.mutex.Lock()
	defer s.mutex.Unlock()

	// Add value to set
	s.m[value] = struct{}{}

	// Return inverse, so true if element already existed
	return !found
}
156330
func (s *Set) Add(x uint32) {
	v := s.sparse[x]
	if v < uint32(len(s.dense)) && s.dense[v] == x {
		return
	}
	n := len(s.dense)
	s.sparse[x] = uint32(n)
	s.dense = append(s.dense, x)
}
245356
func (db *RedisDB) SetAdd(k string, elems ...string) (int, error) {
	db.master.Lock()
	defer db.master.Unlock()
	if db.exists(k) && db.t(k) != "set" {
		return 0, ErrWrongType
	}
	return db.setAdd(k, elems...), nil
}
656478
func (s *Set) Add(value string) error {
	if s.name == nil {
		return ErrDoesNotExist
	}
	exists, err := s.Has(value)
	if err != nil {
		return err
	}
	if exists {
		return ErrExistsInSet
	}
	return (*bbolt.DB)(s.db).Update(func(tx *bbolt.Tx) error {
		bucket := tx.Bucket(s.name)
		if bucket == nil {
			return ErrBucketNotFound
		}
		n, err := bucket.NextSequence()
		if err != nil {
			return err
		}
		return bucket.Put(byteID(n), []byte(value))
	})
}
901775
func (set StringSet) Add(i string) bool {
	_, found := set[i]
	set[i] = struct{}{}
	return !found //False if it e  xisted already
}
619412
func (m *Miniredis) Members(k string) ([]string, error) {
	return m.DB(m.selectedDB).Members(k)
}
975766
func (k *keyset) Add(bundle *libkb.PGPKeyBundle) {
	kid := bundle.GetKID()
	if _, ok := k.keys[kid]; ok {
		return
	}
	k.keys[kid] = bundle
	k.index = append(k.index, kid)
}
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()
}
462034
func (set IdentifierSet) Add(i Identifier) bool {
	_, found := set[i]
	set[i] = struct{}{}
	return !found //False if it existed already
}
1267083
func (c *Consistent) add(elt string) {
	for i := 0; i < c.NumberOfReplicas; i++ {
		c.circle[c.hashKey(c.eltKey(elt, i))] = elt
	}
	c.members[elt] = true
	c.updateSortedHashes()
	c.count++
}