mirror of https://github.com/go-redis/redis.git
Merge pull request #207 from go-redis/fix/zstore-weight
Fix ZStore Weight type. Fixes #206.
This commit is contained in:
commit
5efe0cceb6
12
commands.go
12
commands.go
|
@ -990,15 +990,15 @@ func (c *commandable) SUnionStore(destination string, keys ...string) *IntCmd {
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Sorted set member.
|
// Z represents sorted set member.
|
||||||
type Z struct {
|
type Z struct {
|
||||||
Score float64
|
Score float64
|
||||||
Member interface{}
|
Member interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorted set store operation.
|
// ZStore is used as an arg to ZInterStore and ZUnionStore.
|
||||||
type ZStore struct {
|
type ZStore struct {
|
||||||
Weights []int64
|
Weights []float64
|
||||||
// Can be SUM, MIN or MAX.
|
// Can be SUM, MIN or MAX.
|
||||||
Aggregate string
|
Aggregate string
|
||||||
}
|
}
|
||||||
|
@ -1113,11 +1113,7 @@ func (c *commandable) ZIncrBy(key string, increment float64, member string) *Flo
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandable) ZInterStore(
|
func (c *commandable) ZInterStore(destination string, store ZStore, keys ...string) *IntCmd {
|
||||||
destination string,
|
|
||||||
store ZStore,
|
|
||||||
keys ...string,
|
|
||||||
) *IntCmd {
|
|
||||||
args := make([]interface{}, 3+len(keys))
|
args := make([]interface{}, 3+len(keys))
|
||||||
args[0] = "ZINTERSTORE"
|
args[0] = "ZINTERSTORE"
|
||||||
args[1] = destination
|
args[1] = destination
|
||||||
|
|
|
@ -2082,7 +2082,7 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
zInterStore := client.ZInterStore(
|
zInterStore := client.ZInterStore(
|
||||||
"out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2")
|
"out", redis.ZStore{Weights: []float64{2, 3}}, "zset1", "zset2")
|
||||||
Expect(zInterStore.Err()).NotTo(HaveOccurred())
|
Expect(zInterStore.Err()).NotTo(HaveOccurred())
|
||||||
Expect(zInterStore.Val()).To(Equal(int64(2)))
|
Expect(zInterStore.Val()).To(Equal(int64(2)))
|
||||||
|
|
||||||
|
@ -2479,7 +2479,7 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
Expect(zAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
zUnionStore := client.ZUnionStore(
|
zUnionStore := client.ZUnionStore(
|
||||||
"out", redis.ZStore{Weights: []int64{2, 3}}, "zset1", "zset2")
|
"out", redis.ZStore{Weights: []float64{2, 3}}, "zset1", "zset2")
|
||||||
Expect(zUnionStore.Err()).NotTo(HaveOccurred())
|
Expect(zUnionStore.Err()).NotTo(HaveOccurred())
|
||||||
Expect(zUnionStore.Val()).To(Equal(int64(3)))
|
Expect(zUnionStore.Val()).To(Equal(int64(3)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue