Skip to content

Commit

Permalink
Go: XDel update documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Prateek Kumar <[email protected]>
  • Loading branch information
prateek-kumar-improving committed Jan 13, 2025
1 parent 5c4a4cb commit c2d25be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
25 changes: 25 additions & 0 deletions go/api/base_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,31 @@ func (client *baseClient) XLen(key string) (Result[int64], error) {
return handleLongResponse(result)
}

// Removes the specified entries by id from a stream, and returns the number of entries deleted.
//
// See [valkey.io] for details.
//
// Parameters:
//
// key - The key of the stream.
// ids - An array of entry ids.
//
// Return value:
//
// int64 - The number of entries removed from the stream. This number may be less than the number
// of entries in `ids`, if the specified `ids` don't exist in the stream.
//
// For example:
//
// xAddResult, err := client.XAddWithOptions(
// "key1",
// [][]string{{"f1", "foo1"}, {"f2", "bar2"}},
// options.NewXAddOptions().SetId(streamId1),
// )
// xDelResult, err := client.XDel("key1", []string{streamId1, streamId3})
// fmt.Println(xDelResult.Value()) // Output: 1
//
// [valkey.io]: https://valkey.io/commands/xdel/
func (client *baseClient) XDel(key string, ids []string) (int64, error) {
result, err := client.executeCommand(C.XDel, append([]string{key}, ids...))
if err != nil {
Expand Down
22 changes: 0 additions & 22 deletions go/api/stream_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,5 @@ type StreamCommands interface {
// [valkey.io]: https://valkey.io/commands/xlen/
XLen(key string) (Result[int64], error)

// Removes the specified entries by id from a stream, and returns the number of entries deleted.
//
// See [valkey.io] for details.
//
// Parameters:
// key - The key of the stream.
// ids - An array of entry ids.
//
// Return value:
// int64 - The number of entries removed from the stream. This number may be less than the number
// of entries in `ids`, if the specified `ids` don't exist in the stream.
//
// For example:
// xAddResult, err := client.XAddWithOptions(
// "key1",
// [][]string{{"f1", "foo1"}, {"f2", "bar2"}},
// options.NewXAddOptions().SetId(streamId1),
// )
// xDelResult, err := client.XDel("key1", []string{streamId1, streamId3})
// fmt.Println(xDelResult.Value()) // Output: 1
//
// [valkey.io]: https://valkey.io/commands/xdel/
XDel(key string, ids []string) (int64, error)
}

0 comments on commit c2d25be

Please sign in to comment.