Skip to content

Commit

Permalink
reducing dup code & doc fix
Browse files Browse the repository at this point in the history
Signed-off-by: TJ Zhang <[email protected]>
  • Loading branch information
TJ Zhang committed Jan 23, 2025
1 parent 5b036bb commit 1d8ec2a
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions go/api/base_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3599,28 +3599,23 @@ func (client *baseClient) CopyWithOptions(
// options.NewInfiniteStreamBoundary(options.NegativeInfinity),
// options.NewInfiniteStreamBoundary(options.PositiveInfinity),
// )
// fmt.Println(res) // Output: map[key:[["field1", "entry1"], ["field2", "entry2"]]]
// fmt.Println(res) // map[key:[["field1", "entry1"], ["field2", "entry2"]]]
//
// // Retrieve exactly one stream entry by id
// res, err := client.XRange(
// "key",
// options.NewStreamBoundary(streamId, true),
// options.NewStreamBoundary(streamId, true),
// )
// fmt.Println(res) // Output: map[key:[["field1", "entry1"]]
// fmt.Println(res) // map[key:[["field1", "entry1"]]
//
// [valkey.io]: https://valkey.io/commands/xrange/
func (client *baseClient) XRange(
key string,
start options.StreamBoundary,
end options.StreamBoundary,
) (map[string][][]string, error) {
args := []string{key, string(start), string(end)}
result, err := client.executeCommand(C.XRange, args)
if err != nil {
return nil, err
}
return handleMapOfArrayOfStringArrayOrNilResponse(result)
return client.XRangeWithOptions(key, start, end, nil)
}

// Returns stream entries matching a given range of IDs.
Expand Down Expand Up @@ -3652,7 +3647,7 @@ func (client *baseClient) XRange(
// options.NewInfiniteStreamBoundary(options.PositiveInfinity),
// options.NewStreamRangeOptions().SetCount(10),
// )
// fmt.Println(res) // Output: map[key:[["field1", "entry1"], ["field2", "entry2"]]]
// fmt.Println(res) // map[key:[["field1", "entry1"], ["field2", "entry2"]]]
//
// // Retrieve exactly one stream entry by id
// res, err := client.XRangeWithCount(
Expand All @@ -3661,7 +3656,7 @@ func (client *baseClient) XRange(
// options.NewStreamBoundary(streamId, true),
// options.NewStreamRangeOptions().SetCount(1),
// )
// fmt.Println(res) // Output: map[key:[["field1", "entry1"]]
// fmt.Println(res) // map[key:[["field1", "entry1"]]
//
// [valkey.io]: https://valkey.io/commands/xrange/
func (client *baseClient) XRangeWithOptions(
Expand Down Expand Up @@ -3713,20 +3708,15 @@ func (client *baseClient) XRangeWithOptions(
// options.NewInfiniteStreamBoundary(options.PositiveInfinity),
// options.NewInfiniteStreamBoundary(options.NegativeInfinity),
// )
// fmt.Println(res) // Output: map[key:[["field2", "entry2"], ["field1", "entry1"]]]
// fmt.Println(res) // map[key:[["field2", "entry2"], ["field1", "entry1"]]]
//
// [valkey.io]: https://valkey.io/commands/xrevrange/
func (client *baseClient) XRevRange(
key string,
start options.StreamBoundary,
end options.StreamBoundary,
) (map[string][][]string, error) {
args := []string{key, string(start), string(end)}
result, err := client.executeCommand(C.XRevRange, args)
if err != nil {
return nil, err
}
return handleMapOfArrayOfStringArrayOrNilResponse(result)
return client.XRevRangeWithOptions(key, start, end, nil)
}

// Returns stream entries matching a given range of IDs in reverse order.
Expand Down Expand Up @@ -3760,7 +3750,7 @@ func (client *baseClient) XRevRange(
// options.NewInfiniteStreamBoundary(options.NegativeInfinity),
// options.NewStreamRangeOptions().SetCount(10),
// )
// fmt.Println(res) // Output: map[key:[["field2", "entry2"], ["field1", "entry1"]]]
// fmt.Println(res) // map[key:[["field2", "entry2"], ["field1", "entry1"]]]
//
// [valkey.io]: https://valkey.io/commands/xrevrange/
func (client *baseClient) XRevRangeWithOptions(
Expand Down

0 comments on commit 1d8ec2a

Please sign in to comment.