Fix ZStore Weight type. Fixes .

This commit is contained in:
Vladimir Mihailenco 2015-12-01 16:28:41 +02:00
parent 54a9acc11f
commit 83b8c0a9c0
2 changed files with 6 additions and 10 deletions

View File

@ -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

View File

@ -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)))