Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I follow the command? #25

Open
viney opened this issue Jul 12, 2013 · 2 comments
Open

How do I follow the command? #25

viney opened this issue Jul 12, 2013 · 2 comments

Comments

@viney
Copy link

viney commented Jul 12, 2013

ZRANGE test_name 0 -1 withscores

This‘s method.
func (client *Client) Zrange(key string, start int, end int) ([][]byte, error)

Can not meet the conditions.

If you want to design like this?
func (client *Client) Zrange(key string, start int, end int) ([]map[[]byte]uint64, error)

@codeskyblue
Copy link

@viney I meet the question too. So I write add some code for convertision. http://github.com/shxsun/redis, I send a pull request but not been merged.

var x []string
x, err := redis.Strings(redis.Zrange(key, 0, -1))

@viney
Copy link
Author

viney commented Jul 15, 2013

@shxsun
I fix local code like this:

// 获取有序集合中所有成员和score
// 并获取成员对应的score值

func Zrevrange(key string, start int, end int) (map[string]float64, error) {
bytes, err := client.Zrevrange(key, start, end)
if err != nil {
return nil, err
}

var ret = make(map[string]float64)
if len(bytes) > 0 {
    for _, member := range bytes {
        f, err := client.Zscore(key, member)
        if err != nil {
            return nil, err
        }
        ret[string(member)] = f
    }
}
return ret, nil

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants