add redis Zrevrank (#137)

* update goctl rpc template log print url

* add redis Zrevrank

Co-authored-by: zhangkai <zhangkai@laoyuegou.com>
This commit is contained in:
mywaystay
2020-10-19 15:30:19 +08:00
committed by GitHub
parent 81bf122fa4
commit 33faab61a3
3 changed files with 27 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ type (
ZrevrangebyscoreWithScores(key string, start, stop int64) ([]redis.Pair, error)
ZrevrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) ([]redis.Pair, error)
Zscore(key string, value string) (int64, error)
Zrevrank(key, field string) (int64, error)
}
clusterStore struct {
@@ -644,6 +645,15 @@ func (cs clusterStore) Zscore(key string, value string) (int64, error) {
return node.Zscore(key, value)
}
func (cs clusterStore) Zrevrank(key, field string) (int64, error) {
node, err := cs.getRedis(key)
if err != nil {
return 0, err
}
return node.Zrevrank(key, field)
}
func (cs clusterStore) getRedis(key string) (*redis.Redis, error) {
if val, ok := cs.dispatcher.Get(key); !ok {
return nil, ErrNoRedisNode