ZAdd Adds the specified member with the specified score into the sorted set specified by key in a bucket.
(bucket string, key []byte, score float64, val []byte)
| 35 | |
| 36 | // ZAdd Adds the specified member with the specified score into the sorted set specified by key in a bucket. |
| 37 | func (tx *Tx) ZAdd(bucket string, key []byte, score float64, val []byte) error { |
| 38 | var buffer bytes.Buffer |
| 39 | |
| 40 | if strings.Contains(string(key), SeparatorForZSetKey) { |
| 41 | return ErrSeparatorForZSetKey() |
| 42 | } |
| 43 | |
| 44 | buffer.Write(key) |
| 45 | buffer.Write([]byte(SeparatorForZSetKey)) |
| 46 | scoreBytes := []byte(strconv.FormatFloat(score, 'f', -1, 64)) |
| 47 | buffer.Write(scoreBytes) |
| 48 | newKey := buffer.Bytes() |
| 49 | |
| 50 | return tx.put(bucket, newKey, val, Persistent, DataZAddFlag, uint64(time.Now().Unix()), DataStructureSortedSet) |
| 51 | } |
| 52 | |
| 53 | // ZMembers Returns all the members and scores of members of the set specified by key in a bucket. |
| 54 | func (tx *Tx) ZMembers(bucket string, key []byte) (map[*SortedSetMember]struct{}, error) { |