diff --git a/core/stores/kv/store.go b/core/stores/kv/store.go index d9aa687a..927867c5 100644 --- a/core/stores/kv/store.go +++ b/core/stores/kv/store.go @@ -636,22 +636,22 @@ func (cs clusterStore) ZrevrangebyscoreWithScoresAndLimit(key string, start, sto return node.ZrevrangebyscoreWithScoresAndLimit(key, start, stop, page, size) } -func (cs clusterStore) Zscore(key string, value string) (int64, error) { +func (cs clusterStore) Zrevrank(key, field string) (int64, error) { node, err := cs.getRedis(key) if err != nil { return 0, err } - return node.Zscore(key, value) + return node.Zrevrank(key, field) } -func (cs clusterStore) Zrevrank(key, field string) (int64, error) { +func (cs clusterStore) Zscore(key string, value string) (int64, error) { node, err := cs.getRedis(key) if err != nil { return 0, err } - return node.Zrevrank(key, field) + return node.Zscore(key, value) } func (cs clusterStore) getRedis(key string) (*redis.Redis, error) { diff --git a/core/stores/kv/store_test.go b/core/stores/kv/store_test.go index 36193403..59258c58 100644 --- a/core/stores/kv/store_test.go +++ b/core/stores/kv/store_test.go @@ -516,6 +516,8 @@ func TestRedis_SortedSet(t *testing.T) { assert.NotNil(t, err) _, err = store.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 1) assert.NotNil(t, err) + _, err = store.Zrevrank("key", "value") + assert.NotNil(t, err) _, err = store.Zadds("key", redis.Pair{ Key: "value2", Score: 6, @@ -640,6 +642,9 @@ func TestRedis_SortedSet(t *testing.T) { Score: 5, }, }, pairs) + rank, err = client.Zrevrank("key", "value1") + assert.Nil(t, err) + assert.Equal(t, int64(1), rank) val, err = client.Zadds("key", redis.Pair{ Key: "value2", Score: 6, diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go index f804160f..3ea5f212 100644 --- a/core/stores/redis/redis_test.go +++ b/core/stores/redis/redis_test.go @@ -713,6 +713,8 @@ func TestRedis_SortedSet(t *testing.T) { pairs, err = client.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 0) assert.Nil(t, err) assert.Equal(t, 0, len(pairs)) + _, err = NewRedis(client.Addr, "").Zrevrank("key", "value") + assert.NotNil(t, err) }) }