package redisimport// SetCmdable is an interface for Redis set commands.// Sets are unordered collections of unique strings.typeSetCmdableinterface {SAdd(ctx context.Context, key string, members ...interface{}) *IntCmdSCard(ctx context.Context, key string) *IntCmdSDiff(ctx context.Context, keys ...string) *StringSliceCmdSDiffCard(ctx context.Context, opts *SDiffCardOptions, keys ...string) *IntCmdSDiffStore(ctx context.Context, destination string, keys ...string) *IntCmdSInter(ctx context.Context, keys ...string) *StringSliceCmdSInterCard(ctx context.Context, limit int64, keys ...string) *IntCmdSInterStore(ctx context.Context, destination string, keys ...string) *IntCmdSIsMember(ctx context.Context, key string, member interface{}) *BoolCmdSMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmdSMembers(ctx context.Context, key string) *StringSliceCmdSMembersMap(ctx context.Context, key string) *StringStructMapCmdSMove(ctx context.Context, source, destination string, member interface{}) *BoolCmdSPop(ctx context.Context, key string) *StringCmdSPopN(ctx context.Context, key string, count int64) *StringSliceCmdSRandMember(ctx context.Context, key string) *StringCmdSRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmdSRem(ctx context.Context, key string, members ...interface{}) *IntCmdSScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmdSUnion(ctx context.Context, keys ...string) *StringSliceCmdSUnionCard(ctx context.Context, opts *SUnionCardOptions, keys ...string) *IntCmdSUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd}// SUnionCardOptions are the options for SUnionCard.typeSUnionCardOptionsstruct { Approx bool// use an approximate (HyperLogLog) count. Limit int64// cap the result; 0 means no limit.}// SDiffCardOptions are the options for SDiffCard.typeSDiffCardOptionsstruct { Limit int64// cap the result; 0 means no limit.}// Returns the number of elements that were added to the set, not including all// the elements already present in the set.//// For more information about the command please refer to [SADD].//// [SADD]: (https://redis.io/docs/latest/commands/sadd/)func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd { := make([]interface{}, 2, 2+len()) [0] = "sadd" [1] = = appendArgs(, ) := NewIntCmd(, ...) _ = (, )return}// Returns the set cardinality (number of elements) of the set stored at key.// Returns 0 if key does not exist.//// For more information about the command please refer to [SCARD].//// [SCARD]: (https://redis.io/docs/latest/commands/scard/)func ( cmdable) ( context.Context, string) *IntCmd { := NewIntCmd(, "scard", ) _ = (, )return}// Returns the members of the set resulting from the difference between the first set// and all the successive sets.// Keys that do not exist are considered to be empty sets.//// For more information about the command please refer to [SDIFF].//// [SDIFF]: (https://redis.io/docs/latest/commands/sdiff/)func ( cmdable) ( context.Context, ...string) *StringSliceCmd { := make([]interface{}, 1+len()) [0] = "sdiff"for , := range { [1+] = } := NewStringSliceCmd(, ...) _ = (, )return}// Stores the members of the set resulting from the difference between the first set// and all the successive sets into destination.// If destination already exists, it is overwritten.//// For more information about the command please refer to [SDIFFSTORE].//// [SDIFFSTORE]: (https://redis.io/docs/latest/commands/sdiffstore/)func ( cmdable) ( context.Context, string, ...string) *IntCmd { := make([]interface{}, 2+len()) [0] = "sdiffstore" [1] = for , := range { [2+] = } := NewIntCmd(, ...) _ = (, )return}// Returns the cardinality of the difference of the first set and the rest.// Missing keys are treated as empty sets.//// For more information about the command please refer to [SDIFFCARD].//// [SDIFFCARD]: (https://redis.io/docs/latest/commands/sdiffcard/)func ( cmdable) ( context.Context, *SDiffCardOptions, ...string) *IntCmd {if == nil { = &SDiffCardOptions{} } := len() := make([]interface{}, 0, 4+) = append(, "sdiffcard", )for , := range { = append(, ) } = append(, "limit", .Limit) := NewIntCmd(, ...)// Keys start after the numkeys arg: ["sdiffcard", numKeys, key1, ...]. .SetFirstKeyPos(2) _ = (, )return}// Returns the members of the set resulting from the intersection of all the given sets.// Keys that do not exist are considered to be empty sets.// With one of the keys being an empty set, the resulting set is also empty.//// For more information about the command please refer to [SINTER].//// [SINTER]: (https://redis.io/docs/latest/commands/sinter/)func ( cmdable) ( context.Context, ...string) *StringSliceCmd { := make([]interface{}, 1+len()) [0] = "sinter"for , := range { [1+] = } := NewStringSliceCmd(, ...) _ = (, )return}// Returns the cardinality of the set resulting from the intersection of all the given sets.// Keys that do not exist are considered to be empty sets.// With one of the keys being an empty set, the resulting set is also empty.//// The limit parameter sets an upper bound on the number of results returned.// If limit is 0, no limit is applied.//// For more information about the command please refer to [SINTERCARD].//// [SINTERCARD]: (https://redis.io/docs/latest/commands/sintercard/)func ( cmdable) ( context.Context, int64, ...string) *IntCmd { := len() := make([]interface{}, 4+) [0] = "sintercard" [1] = for , := range { [2+] = } [2+] = "limit" [3+] = := NewIntCmd(, ...)// The key follows numkeys, not args[1]: route by it.iflen() > 0 { .SetFirstKeyPos(2) } _ = (, )return}// Stores the members of the set resulting from the intersection of all the given sets// into destination.// If destination already exists, it is overwritten.//// For more information about the command please refer to [SINTERSTORE].//// [SINTERSTORE]: (https://redis.io/docs/latest/commands/sinterstore/)func ( cmdable) ( context.Context, string, ...string) *IntCmd { := make([]interface{}, 2+len()) [0] = "sinterstore" [1] = for , := range { [2+] = } := NewIntCmd(, ...) _ = (, )return}// Returns if member is a member of the set stored at key.// Returns true if the element is a member of the set, false if it is not a member// or if key does not exist.//// For more information about the command please refer to [SISMEMBER].//// [SISMEMBER]: (https://redis.io/docs/latest/commands/sismember/)func ( cmdable) ( context.Context, string, interface{}) *BoolCmd { := NewBoolCmd(, "sismember", , ) _ = (, )return}// Returns whether each member is a member of the set stored at key.// For each member, returns true if the element is a member of the set, false if it is not// a member or if key does not exist.//// For more information about the command please refer to [SMISMEMBER].//// [SMISMEMBER]: (https://redis.io/docs/latest/commands/smismember/)func ( cmdable) ( context.Context, string, ...interface{}) *BoolSliceCmd { := make([]interface{}, 2, 2+len()) [0] = "smismember" [1] = = appendArgs(, ) := NewBoolSliceCmd(, ...) _ = (, )return}// Returns all the members of the set value stored at key.// Returns an empty slice if key does not exist.//// For more information about the command please refer to [SMEMBERS].//// [SMEMBERS]: (https://redis.io/docs/latest/commands/smembers/)func ( cmdable) ( context.Context, string) *StringSliceCmd { := NewStringSliceCmd(, "smembers", ) _ = (, )return}// Returns all the members of the set value stored at key as a map.// Returns an empty map if key does not exist.//// For more information about the command please refer to [SMEMBERS].//// [SMEMBERS]: (https://redis.io/docs/latest/commands/smembers/)func ( cmdable) ( context.Context, string) *StringStructMapCmd { := NewStringStructMapCmd(, "smembers", ) _ = (, )return}// Moves member from the set at source to the set at destination.// This operation is atomic. In every given moment the element will appear to be a member// of source or destination for other clients.//// For more information about the command please refer to [SMOVE].//// [SMOVE]: (https://redis.io/docs/latest/commands/smove/)func ( cmdable) ( context.Context, , string, interface{}) *BoolCmd { := NewBoolCmd(, "smove", , , ) _ = (, )return}// Removes and returns one or more random members from the set value stored at key.// This version returns a single random member.//// For more information about the command please refer to [SPOP].//// [SPOP]: (https://redis.io/docs/latest/commands/spop/)func ( cmdable) ( context.Context, string) *StringCmd { := NewStringCmd(, "spop", ) _ = (, )return}// Removes and returns one or more random members from the set value stored at key.// This version returns up to count random members.//// For more information about the command please refer to [SPOP].//// [SPOP]: (https://redis.io/docs/latest/commands/spop/)func ( cmdable) ( context.Context, string, int64) *StringSliceCmd { := NewStringSliceCmd(, "spop", , ) _ = (, )return}// Returns a random member from the set value stored at key.// This version returns a single random member without removing it.//// For more information about the command please refer to [SRANDMEMBER].//// [SRANDMEMBER]: (https://redis.io/docs/latest/commands/srandmember/)func ( cmdable) ( context.Context, string) *StringCmd { := NewStringCmd(, "srandmember", ) _ = (, )return}// Returns an array of random members from the set value stored at key.// This version returns up to count random members without removing them.// When called with a positive count, returns distinct elements.// When called with a negative count, allows for repeated elements.//// For more information about the command please refer to [SRANDMEMBER].//// [SRANDMEMBER]: (https://redis.io/docs/latest/commands/srandmember/)func ( cmdable) ( context.Context, string, int64) *StringSliceCmd { := NewStringSliceCmd(, "srandmember", , ) _ = (, )return}// Removes the specified members from the set stored at key.// Specified members that are not a member of this set are ignored.// If key does not exist, it is treated as an empty set and this command returns 0.//// For more information about the command please refer to [SREM].//// [SREM]: (https://redis.io/docs/latest/commands/srem/)func ( cmdable) ( context.Context, string, ...interface{}) *IntCmd { := make([]interface{}, 2, 2+len()) [0] = "srem" [1] = = appendArgs(, ) := NewIntCmd(, ...) _ = (, )return}// Returns the members of the set resulting from the union of all the given sets.// Keys that do not exist are considered to be empty sets.//// For more information about the command please refer to [SUNION].//// [SUNION]: (https://redis.io/docs/latest/commands/sunion/)func ( cmdable) ( context.Context, ...string) *StringSliceCmd { := make([]interface{}, 1+len()) [0] = "sunion"for , := range { [1+] = } := NewStringSliceCmd(, ...) _ = (, )return}// Stores the members of the set resulting from the union of all the given sets// into destination.// If destination already exists, it is overwritten.//// For more information about the command please refer to [SUNIONSTORE].//// [SUNIONSTORE]: (https://redis.io/docs/latest/commands/sunionstore/)func ( cmdable) ( context.Context, string, ...string) *IntCmd { := make([]interface{}, 2+len()) [0] = "sunionstore" [1] = for , := range { [2+] = } := NewIntCmd(, ...) _ = (, )return}// Returns the cardinality of the union of all the given sets.// Missing keys are treated as empty sets.//// For more information about the command please refer to [SUNIONCARD].//// [SUNIONCARD]: (https://redis.io/docs/latest/commands/sunioncard/)func ( cmdable) ( context.Context, *SUnionCardOptions, ...string) *IntCmd {if == nil { = &SUnionCardOptions{} } := len() := make([]interface{}, 0, 4++1) = append(, "sunioncard", )for , := range { = append(, ) }if .Approx { = append(, "approx") } = append(, "limit", .Limit) := NewIntCmd(, ...)// Keys start after the numkeys arg: ["sunioncard", numKeys, key1, ...]. .SetFirstKeyPos(2) _ = (, )return}// Incrementally iterates the set elements stored at key.// This is a cursor-based iterator that allows scanning large sets efficiently.//// Parameters:// - cursor: The cursor value for the iteration (use 0 to start a new scan)// - match: Optional pattern to match elements (empty string means no pattern)// - count: Optional hint about how many elements to return per iteration//// For more information about the command please refer to [SSCAN].//// [SSCAN]: (https://redis.io/docs/latest/commands/sscan/)func ( cmdable) ( context.Context, string, uint64, string, int64) *ScanCmd { := []interface{}{"sscan", , }if != "" { = append(, "match", ) }if > 0 { = append(, "count", ) } := NewScanCmd(, , ...) _ = (, )return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.