ZRevRange retrieves a range of elements from a sorted set (ZSet) in descending order. Inputs: - key: Name of the ZSet - startRank: Initial rank of the desired range - endRank: Final rank of the desired range Output: - An array of ZSetValue, representing elements from the range [startRank, endRank]
(key string, startRank int, endRank int)
| 832 | // - Error if an issue occurs, such as when the key is empty or ZSet retrieval fails |
| 833 | // error |
| 834 | func (zs *ZSetStructure) ZRevRange(key string, startRank int, endRank int) ([]ZSetValue, error) { |
| 835 | if err := checkKey(key); err != nil { |
| 836 | return nil, err |
| 837 | } |
| 838 | keyBytes := stringToBytesWithKey(key) |
| 839 | |
| 840 | zSet, err := zs.getZSetFromDB(keyBytes) |
| 841 | if err != nil { |
| 842 | return nil, err |
| 843 | } |
| 844 | r := zSet.skipList.getRange(startRank, endRank, true) |
| 845 | |
| 846 | // rank zero means no rank found |
| 847 | return r, nil |
| 848 | } |
| 849 | |
| 850 | // The ZCard function returns the size of the dictionary of the sorted set stored at key in the database. |
| 851 | // It takes a string key as an argument. |
nothing calls this directly
no test coverage detected