github.com/gogf/gf/v2@v2.7.4/database/gredis/gredis_redis_group_sorted_set.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gredis 8 9 import ( 10 "context" 11 12 "github.com/gogf/gf/v2/container/gvar" 13 ) 14 15 // IGroupSortedSet manages redis sorted set operations. 16 // Implements see redis.GroupSortedSet. 17 type IGroupSortedSet interface { 18 ZAdd(ctx context.Context, key string, option *ZAddOption, member ZAddMember, members ...ZAddMember) (*gvar.Var, error) 19 ZScore(ctx context.Context, key string, member interface{}) (float64, error) 20 ZIncrBy(ctx context.Context, key string, increment float64, member interface{}) (float64, error) 21 ZCard(ctx context.Context, key string) (int64, error) 22 ZCount(ctx context.Context, key string, min, max string) (int64, error) 23 ZRange(ctx context.Context, key string, start, stop int64, option ...ZRangeOption) (gvar.Vars, error) 24 ZRevRange(ctx context.Context, key string, start, stop int64, option ...ZRevRangeOption) (*gvar.Var, error) 25 ZRank(ctx context.Context, key string, member interface{}) (int64, error) 26 ZRevRank(ctx context.Context, key string, member interface{}) (int64, error) 27 ZRem(ctx context.Context, key string, member interface{}, members ...interface{}) (int64, error) 28 ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (int64, error) 29 ZRemRangeByScore(ctx context.Context, key string, min, max string) (int64, error) 30 ZRemRangeByLex(ctx context.Context, key string, min, max string) (int64, error) 31 ZLexCount(ctx context.Context, key, min, max string) (int64, error) 32 } 33 34 // ZAddOption provides options for function ZAdd. 35 type ZAddOption struct { 36 XX bool // Only update elements that already exist. Don't add new elements. 37 NX bool // Only add new elements. Don't update already existing elements. 38 // Only update existing elements if the new score is less than the current score. 39 // This flag doesn't prevent adding new elements. 40 LT bool 41 42 // Only update existing elements if the new score is greater than the current score. 43 // This flag doesn't prevent adding new elements. 44 GT bool 45 46 // Modify the return value from the number of new elements added, to the total number of elements changed (CH is an abbreviation of changed). 47 // Changed elements are new elements added and elements already existing for which the score was updated. 48 // So elements specified in the command line having the same score as they had in the past are not counted. 49 // Note: normally the return value of ZAdd only counts the number of new elements added. 50 CH bool 51 52 // When this option is specified ZAdd acts like ZIncrBy. Only one score-element pair can be specified in this mode. 53 INCR bool 54 } 55 56 // ZAddMember is element struct for set. 57 type ZAddMember struct { 58 Score float64 59 Member interface{} 60 } 61 62 // ZRangeOption provides extra option for ZRange function. 63 type ZRangeOption struct { 64 ByScore bool 65 ByLex bool 66 // The optional REV argument reverses the ordering, so elements are ordered from highest to lowest score, 67 // and score ties are resolved by reverse lexicographical ordering. 68 Rev bool 69 Limit *ZRangeOptionLimit 70 // The optional WithScores argument supplements the command's reply with the scores of elements returned. 71 WithScores bool 72 } 73 74 // ZRangeOptionLimit provides LIMIT argument for ZRange function. 75 // The optional LIMIT argument can be used to obtain a sub-range from the matching elements 76 // (similar to SELECT LIMIT offset, count in SQL). A negative `Count` returns all elements from the `Offset`. 77 type ZRangeOptionLimit struct { 78 Offset *int 79 Count *int 80 } 81 82 // ZRevRangeOption provides options for function ZRevRange. 83 type ZRevRangeOption struct { 84 WithScores bool 85 }