MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / ZScore

Method ZScore

structure/zset.go:622–639  ·  view source on GitHub ↗

ZScore method retrieves the score associated with the member in a sorted set stored at the key

(key string, member string)

Source from the content-addressed store, hash-verified

620
621// ZScore method retrieves the score associated with the member in a sorted set stored at the key
622func (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/*
642ZRank 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.

Callers

nothing calls this directly

Calls 3

getZSetFromDBMethod · 0.95
checkKeyFunction · 0.85
stringToBytesWithKeyFunction · 0.85

Tested by

no test coverage detected