Skip to content

Commit

Permalink
update examples doc
Browse files Browse the repository at this point in the history
Signed-off-by: TJ Zhang <tj.zhang@improving.com>
  • Loading branch information
TJ Zhang committed Dec 10, 2024
1 parent af06931 commit 726a0b9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions go/api/set_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ type SetCommands interface {
// The second element is always an array of the subset of the set held in `key`.
//
// Example:
// // assume "key" contains a set with 130 members
// resultCursor := "0"
// for true {
// resCursor, resCol, err := client.sscan("key", "0", opts)
// fmt.Println("Cursor: ", resCursor)
// fmt.Println("Members: ", resCol)
// if resCursor == "0" {
// break
// }
// }
//
// [valkey.io]: https://valkey.io/commands/sscan/
SScan(key string, cursor string) (string, []string, error)
Expand All @@ -312,6 +322,23 @@ type SetCommands interface {
// The second element is always an array of the subset of the set held in `key`.
//
// Example:
// // assume "key" contains a set with 130 members
// resultCursor := "0"
// for true {
// opts := api.NewBaseScanOptionsBuilder().SetMatch("*")
// resCursor, resCol, err := client.sscan("key", "0", opts)
// fmt.Println("Cursor: ", resCursor)
// fmt.Println("Members: ", resCol)
// if resCursor == "0" {
// break
// }
// }
// Cursor: 48
// Members: ['3', '118', '120', '86', '76', '13', '61', '111', '55', '45']
// Cursor: 24
// Members: ['38', '109', '11', '119', '34', '24', '40', '57', '20', '17']
// Cursor: 0
// Members: ['47', '122', '1', '53', '10', '14', '80']
//
// [valkey.io]: https://valkey.io/commands/sscan/
SScanWithOption(key string, cursor string, options *BaseScanOptions) (string, []string, error)
Expand All @@ -330,6 +357,8 @@ type SetCommands interface {
// `true` on success, or `false` if the `source` set does not exist or the element is not a member of the source set.
//
// Example:
// moved := SMove("set1", "set2", "element")
// fmt.Println(moved) // output: true
//
// [valkey.io]: https://valkey.io/commands/smove/
SMove(source string, destination string, member string) (Result[bool], error)
Expand Down

0 comments on commit 726a0b9

Please sign in to comment.