// ZAdd adds a score,member to a sorted set.
3655
func (m *Miniredis) ZAdd(k string, score float64, member string) (bool, error) {
	return m.DB(m.selectedDB).ZAdd(k, score, member)
}
1149962
func (db *RedisDB) ZMembers(k string) ([]string, error) {
	db.master.Lock()
	defer db.master.Unlock()
	if !db.exists(k) {
		return nil, ErrKeyNotFound
	}
	if db.t(k) != "zset" {
		return nil, ErrWrongType
	}
	return db.ssetMembers(k), nil
}
1190548
func (ml *MockRouteCountLogger) CounterD(title string, value int, data map[string]interface{}) {
	ml.logger.CounterD(title, value, data)
}
894537
func (t *tNode) untombed() *sNode {
	return &sNode{&Entry{Key: t.Key, hash: t.hash, Value: t.Value}}
}
724795
func (scg scanCommandGroup) xzscanCommand(c *client) error {
	args := c.args

	if len(args) < 2 {
		return ErrCmdParams
	}

	key := args[0]

	cursor, match, count, desc, err := scg.parseArgs(args[1:])

	if err != nil {
		return err
	}

	var ay []ledis.ScorePair

	if !desc {
		ay, err = c.db.ZScan(key, cursor, count, false, match)
	} else {
		ay, err = c.db.ZRevScan(key, cursor, count, false, match)
	}

	if err != nil {
		return err
	}

	data := make([]interface{}, 2)
	if len(ay) < count {
		data[0] = scg.lastCursor
	} else {
		data[0] = ay[len(ay)-1].Member
	}

	vv := make([][]byte, 0, len(ay)*2)

	for _, v := range ay {
		vv = append(vv, v.Member, num.FormatInt64ToSlice(v.Score))
	}

	data[1] = vv

	c.resp.writeArray(data)
	return nil
}
1013541
func addObject(data []byte, adder models.Adder, id string, conn redis.Conn) {
	_ = conn.Send("SET", id, data)

	for _, cmd := range adder.Add() {
		switch cmd.Command {
		case "ZADD":
			_ = conn.Send(cmd.Command, cmd.Hash, cmd.Rank, cmd.Key)
		case "SADD":
			_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key)
		case "HSET":
			_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key, cmd.Value)
		}
	}
}
87655
func (c *Client) ZRangeByScore(key string, min int, max int, withscores bool, limit bool, offset int, count int) ([]string, error) {
	var v interface{}
	var err error

	if withscores == true {
		if limit {
			v, err = c.execWithKey(true, "ZRANGEBYSCORE", key, min, max, "WITHSCORES", "LIMIT", offset, count)
		} else {
			v, err = c.execWithKey(true, "ZRANGEBYSCORE", key, min, max, "WITHSCORES")
		}
	} else {
		if limit {
			v, err = c.execWithKey(true, "ZRANGEBYSCORE", key, min, max, "LIMIT", offset, count)
		} else {
			v, err = c.execWithKey(true, "ZRANGEBYSCORE", key, min, max)
		}
	}

	if err != nil {
		return nil, err
	}
	return iface2vstr(v), nil
}
667406
func (h *Handle) QdiscAdd(qdisc Qdisc) error {
	return h.qdiscModify(
		unix.RTM_NEWQDISC,
		unix.NLM_F_CREATE|unix.NLM_F_EXCL,
		qdisc)
}
903771
func (c *Client) ZCount(key string, min int, max int) (int, error) {
	v, err := c.execWithKey(true, "ZCOUNT", key, min, max)

	if err != nil {
		return 0, err
	}
	return iface2int(v)
}
708983
func (_m *Group) ID() string {
	ret := _m.Called()

	var r0 string
	if rf, ok := ret.Get(0).(func() string); ok {
		r0 = rf()
	} else {
		r0 = ret.Get(0).(string)
	}

	return r0
}
75142
func (cache *DiskBlockCacheLocal) shuffleTLFsAtPriorityWeighted(
	priority evictionPriority) []weightedByCount {
	weightedSlice := make([]weightedByCount, 0,
		len(cache.priorityTlfMap[priority]))
	idx := 0
	// Use an exponential distribution to ensure the weights are
	// correctly used.
	// See http://utopia.duth.gr/~pefraimi/research/data/2007EncOfAlg.pdf
	for tlfID, count := range cache.priorityTlfMap[priority] {
		if count == 0 {
			continue
		}
		weightedSlice = append(weightedSlice, weightedByCount{
			key:   math.Pow(rand.Float64(), 1.0/float64(count)),
			value: tlfID,
		})
		idx++
	}
	sort.Slice(weightedSlice, func(i, j int) bool {
		return weightedSlice[i].key > weightedSlice[j].key
	})
	return weightedSlice
}
676941
func (l Levels) Crit() log.Logger {
	return log.WithPrefix(l.logger, l.levelKey, l.critValue)
}
1243027
func (t *Tracer) randomID() uint64 {
	val := t.randomNumber()
	for val == 0 {
		val = t.randomNumber()
	}
	return val
}
414621
func (db *RedisDB) sortedSet(key string) map[string]float64 {
	ss := db.sortedsetKeys[key]
	return map[string]float64(ss)
}
35268
func (db *DB) ZDump(key []byte) ([]byte, error) {
	v, err := db.ZRangeByScore(key, MinScore, MaxScore, 0, -1)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	o := make(rdb.ZSet, len(v))
	for i := 0; i < len(v); i++ {
		o[i].Member = v[i].Member
		o[i].Score = float64(v[i].Score)
	}

	return rdb.Dump(o)
}
1007105
func (s *State) SetDead() {
	s.Lock()
	s.Dead = true
	s.Unlock()
}
307757
func (h *Hive) Peer(id enode.ID) *BzzPeer {
	h.lock.Lock()
	defer h.lock.Unlock()

	return h.peers[id]
}