ZScore method retrieves the score associated with the member in a sorted set stored at the key
(key string, member string)
| 620 | |
| 621 | // ZScore method retrieves the score associated with the member in a sorted set stored at the key |
| 622 | func (zs *ZSetStructure) ZScore(key string, member string) (int, error) { |
| 623 | if err := checkKey(key); err != nil { |
| 624 | return 0, err |
| 625 | } |
| 626 | keyBytes := stringToBytesWithKey(key) |
| 627 | |
| 628 | zSet, err := zs.getZSetFromDB(keyBytes) |
| 629 | if err != nil { |
| 630 | return 0, err |
| 631 | } |
| 632 | // if the member in the sorted set is found, return the score associated with it |
| 633 | if v, ok := zSet.dict[member]; ok { |
| 634 | return v.score, nil |
| 635 | } |
| 636 | |
| 637 | // if the member doesn't exist in the set, return score of zero and an error |
| 638 | return 0, _const.ErrKeyNotFound |
| 639 | } |
| 640 | |
| 641 | /* |
| 642 | ZRank is a method belonging to the ZSetStructure type. This method retrieves the rank of an element within a sorted set identified by a key. The rank is an integer corresponding to the element's 0-based position in the sorted set when it is arranged in ascending order. |
nothing calls this directly
no test coverage detected