Beispiel #1
0
func redisInsert(key string, score int64, data []byte) (err error) {
	c := r.GetClient()
	defer c.Quit()

	success, err := c.Zadd(key, float64(score), data)
	if err != nil {
		return err
	} else if !success {
		return errors.New("insert " + key + " failed")
	}
	return
}
Beispiel #2
0
func RemoveKey(key string) (err error) {
	log.Warnf("remove key: %s", key)
	c := r.GetClient()
	defer c.Quit()

	success, err := c.Del(key)
	if err != nil {
		return err
	} else if !success {
		return errors.New("delete key " + key + " failed")
	}
	return nil
}
Beispiel #3
0
func redisStrs(key string, from int64, to int64) (rets []string, err error) {
	c := r.GetClient()
	defer c.Quit()

	var bytess [][]byte
	bytess, err = c.Zrevrange(key, from, to)
	if err != nil {
		return
	}

	rets = make([]string, len(bytess))
	for pos, v := range bytess {
		rets[pos] = string(v)
	}
	log.Infof("size: %d, ids: %+v", len(rets), rets)
	return rets, nil
}