ZCount Returns the number of elements in the sorted set specified by key in a bucket with a score between min and max and opts. Opt includes the following parameters: Limit int // limit the max nodes to return ExcludeStart bool // exclude start value, so it search in interval (start, end] or
(bucket string, key []byte, start, end float64, opts *GetByScoreRangeOptions)
| 121 | // ExcludeStart bool // exclude start value, so it search in interval (start, end] or (start, end) |
| 122 | // ExcludeEnd bool // exclude end value, so it search in interval [start, end) or (start, end) |
| 123 | func (tx *Tx) ZCount(bucket string, key []byte, start, end float64, opts *GetByScoreRangeOptions) (int, error) { |
| 124 | if err := tx.ZCheck(bucket); err != nil { |
| 125 | return 0, err |
| 126 | } |
| 127 | |
| 128 | b, err := tx.db.bucketMgr.GetBucket(DataStructureSortedSet, bucket) |
| 129 | if err != nil { |
| 130 | return 0, err |
| 131 | } |
| 132 | |
| 133 | var ( |
| 134 | bucketId = b.Id |
| 135 | sortedSet *SortedSet |
| 136 | exist bool |
| 137 | ) |
| 138 | |
| 139 | if sortedSet, exist = tx.db.Index.SortedSet.exist(bucketId); !exist { |
| 140 | return 0, ErrBucket |
| 141 | } |
| 142 | |
| 143 | return sortedSet.ZCount(string(key), SCORE(start), SCORE(end), opts) |
| 144 | } |
| 145 | |
| 146 | // ZPopMax Removes and returns the member with the highest score in the sorted set specified by key in a bucket. |
| 147 | func (tx *Tx) ZPopMax(bucket string, key []byte) (*SortedSetMember, error) { |