Documentation ¶
Overview ¶
Example ¶
package main import "fmt" var zsetKey = "my_zset" func main() { zset := New() zset.ZAdd(zsetKey, 12.1, "PHP") zset.ZAdd(zsetKey, 34.23, "Java") zset.ZAdd(zsetKey, 23.5, "Python") val := zset.ZGetByRank(zsetKey, 2) for _, v := range val { fmt.Printf("%+v", v) } zset.ZRange(zsetKey, 1, 10) }
Output:
Index ¶
- type SortedSet
- func (z *SortedSet) ZAdd(key string, score float64, member string)
- func (z *SortedSet) ZCard(key string) int
- func (z *SortedSet) ZClear(key string)
- func (z *SortedSet) ZGetByRank(key string, rank int) (val []interface{})
- func (z *SortedSet) ZIncrBy(key string, increment float64, member string) float64
- func (z *SortedSet) ZKeyExists(key string) bool
- func (z *SortedSet) ZRange(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRangeWithScores(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRank(key, member string) int64
- func (z *SortedSet) ZRem(key, member string) bool
- func (z *SortedSet) ZRevGetByRank(key string, rank int) (val []interface{})
- func (z *SortedSet) ZRevRange(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRevRangeWithScores(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRevRank(key, member string) int64
- func (z *SortedSet) ZRevScoreRange(key string, max, min float64) (val []interface{})
- func (z *SortedSet) ZScore(key string, member string) (ok bool, score float64)
- func (z *SortedSet) ZScoreRange(key string, min, max float64) (val []interface{})
- type SortedSetNode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SortedSet ¶
type SortedSet struct {
// contains filtered or unexported fields
}
SortedSet sorted set struct
func (*SortedSet) ZAdd ¶
ZAdd Adds the specified member with the specified score to the sorted set stored at key.
func (*SortedSet) ZCard ¶
ZCard returns the sorted set cardinality (number of elements) of the sorted set stored at key.
func (*SortedSet) ZGetByRank ¶
ZGetByRank 根据排名获取member及分值信息,从小到大排列遍历,即分值最低排名为0,依次类推 Get the member at key by rank, the rank is ordered from lowest to highest. The rank of lowest is 0 and so on.
func (*SortedSet) ZIncrBy ¶
ZIncrBy increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.
func (*SortedSet) ZKeyExists ¶
ZKeyExists check if the key exists in zset.
func (*SortedSet) ZRange ¶
ZRange returns the specified range of elements in the sorted set stored at <key>.
func (*SortedSet) ZRangeWithScores ¶
ZRangeWithScores returns the specified range of elements in the sorted set stored at <key>.
func (*SortedSet) ZRank ¶
ZRank returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.
func (*SortedSet) ZRem ¶
ZRem removes the specified members from the sorted set stored at key. Non existing members are ignored. An error is returned when key exists and does not hold a sorted set.
func (*SortedSet) ZRevGetByRank ¶
ZRevGetByRank get the member at key by rank, the rank is ordered from highest to lowest. The rank of highest is 0 and so on.
func (*SortedSet) ZRevRange ¶
ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
func (*SortedSet) ZRevRangeWithScores ¶
ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
func (*SortedSet) ZRevRank ¶
ZRevRank returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.
func (*SortedSet) ZRevScoreRange ¶
ZRevScoreRange returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min). In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered from high to low scores.
func (*SortedSet) ZScoreRange ¶
ZScoreRange returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max). The elements are considered to be ordered from low to high scores.
type SortedSetNode ¶
type SortedSetNode struct {
// contains filtered or unexported fields
}
SortedSetNode node of sorted set