@@ -6614,3 +6614,205 @@ func (client *baseClient) CopyWithOptions(
66146614 }
66156615 return handleBoolResponse (result )
66166616}
6617+
6618+ // Returns stream entries matching a given range of IDs.
6619+ //
6620+ // See [valkey.io] for details.
6621+ //
6622+ // Parameters:
6623+ //
6624+ // key - The key of the stream.
6625+ // start - The start position.
6626+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6627+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6628+ // end - The end position.
6629+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6630+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6631+ //
6632+ // Return value:
6633+ //
6634+ // A `map` of key to stream entry data, where entry data is an array of
6635+ // pairings with format `[[field, entry], [field, entry], ...]`. Returns `nil` if `count` is non-positive.
6636+ //
6637+ // Example:
6638+ //
6639+ // // Retrieve all stream entries
6640+ // res, err := client.XRange(
6641+ // "key",
6642+ // options.NewInfiniteStreamBoundary(options.NegativeInfinity),
6643+ // options.NewInfiniteStreamBoundary(options.PositiveInfinity),
6644+ // )
6645+ // fmt.Println(res) // map[key:[["field1", "entry1"], ["field2", "entry2"]]]
6646+ //
6647+ // // Retrieve exactly one stream entry by id
6648+ // res, err := client.XRange(
6649+ // "key",
6650+ // options.NewStreamBoundary(streamId, true),
6651+ // options.NewStreamBoundary(streamId, true),
6652+ // )
6653+ // fmt.Println(res) // map[key:[["field1", "entry1"]]
6654+ //
6655+ // [valkey.io]: https://valkey.io/commands/xrange/
6656+ func (client * baseClient ) XRange (
6657+ key string ,
6658+ start options.StreamBoundary ,
6659+ end options.StreamBoundary ,
6660+ ) (map [string ][][]string , error ) {
6661+ return client .XRangeWithOptions (key , start , end , nil )
6662+ }
6663+
6664+ // Returns stream entries matching a given range of IDs.
6665+ //
6666+ // See [valkey.io] for details.
6667+ //
6668+ // Parameters:
6669+ //
6670+ // key - The key of the stream.
6671+ // start - The start position.
6672+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6673+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6674+ // end - The end position.
6675+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6676+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6677+ // opts - Stream range options.
6678+ //
6679+ // Return value:
6680+ //
6681+ // A `map` of key to stream entry data, where entry data is an array of
6682+ // pairings with format `[[field, entry], [field, entry], ...]`. Returns `nil` if `count` is non-positive.
6683+ //
6684+ // Example:
6685+ //
6686+ // // Retrieve all stream entries
6687+ // res, err := client.XRangeWithOptions(
6688+ // "key",
6689+ // options.NewInfiniteStreamBoundary(options.NegativeInfinity),
6690+ // options.NewInfiniteStreamBoundary(options.PositiveInfinity),
6691+ // options.NewStreamRangeOptions().SetCount(10),
6692+ // )
6693+ // fmt.Println(res) // map[key:[["field1", "entry1"], ["field2", "entry2"]]]
6694+ //
6695+ // // Retrieve exactly one stream entry by id
6696+ // res, err := client.XRangeWithOptions(
6697+ // "key",
6698+ // options.NewStreamBoundary(streamId, true),
6699+ // options.NewStreamBoundary(streamId, true),
6700+ // options.NewStreamRangeOptions().SetCount(1),
6701+ // )
6702+ // fmt.Println(res) // map[key:[["field1", "entry1"]]
6703+ //
6704+ // [valkey.io]: https://valkey.io/commands/xrange/
6705+ func (client * baseClient ) XRangeWithOptions (
6706+ key string ,
6707+ start options.StreamBoundary ,
6708+ end options.StreamBoundary ,
6709+ opts * options.StreamRangeOptions ,
6710+ ) (map [string ][][]string , error ) {
6711+ args := []string {key , string (start ), string (end )}
6712+ if opts != nil {
6713+ optionArgs , err := opts .ToArgs ()
6714+ if err != nil {
6715+ return nil , err
6716+ }
6717+ args = append (args , optionArgs ... )
6718+ }
6719+ result , err := client .executeCommand (C .XRange , args )
6720+ if err != nil {
6721+ return nil , err
6722+ }
6723+ return handleMapOfArrayOfStringArrayOrNilResponse (result )
6724+ }
6725+
6726+ // Returns stream entries matching a given range of IDs in reverse order.
6727+ // Equivalent to `XRange` but returns entries in reverse order.
6728+ //
6729+ // See [valkey.io] for details.
6730+ //
6731+ // Parameters:
6732+ //
6733+ // key - The key of the stream.
6734+ // start - The start position.
6735+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6736+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6737+ // end - The end position.
6738+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6739+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6740+ //
6741+ // Return value:
6742+ //
6743+ // A `map` of key to stream entry data, where entry data is an array of
6744+ // pairings with format `[[field, entry], [field, entry], ...]`.
6745+ //
6746+ // Example:
6747+ //
6748+ // // Retrieve all stream entries
6749+ // res, err := client.XRevRange(
6750+ // "key",
6751+ // options.NewInfiniteStreamBoundary(options.PositiveInfinity),
6752+ // options.NewInfiniteStreamBoundary(options.NegativeInfinity),
6753+ // )
6754+ // fmt.Println(res) // map[key:[["field2", "entry2"], ["field1", "entry1"]]]
6755+ //
6756+ // [valkey.io]: https://valkey.io/commands/xrevrange/
6757+ func (client * baseClient ) XRevRange (
6758+ key string ,
6759+ start options.StreamBoundary ,
6760+ end options.StreamBoundary ,
6761+ ) (map [string ][][]string , error ) {
6762+ return client .XRevRangeWithOptions (key , start , end , nil )
6763+ }
6764+
6765+ // Returns stream entries matching a given range of IDs in reverse order.
6766+ // Equivalent to `XRange` but returns entries in reverse order.
6767+ //
6768+ // See [valkey.io] for details.
6769+ //
6770+ // Parameters:
6771+ //
6772+ // key - The key of the stream.
6773+ // start - The start position.
6774+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6775+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6776+ // end - The end position.
6777+ // Use `options.NewStreamBoundary()` to specify a stream entry ID and its inclusive/exclusive status.
6778+ // Use `options.NewInfiniteStreamBoundary()` to specify an infinite stream boundary.
6779+ // opts - Stream range options.
6780+ //
6781+ // Return value:
6782+ //
6783+ // A `map` of key to stream entry data, where entry data is an array of
6784+ // pairings with format `[[field, entry], [field, entry], ...]`.
6785+ // Returns `nil` if `count` is non-positive.
6786+ //
6787+ // Example:
6788+ //
6789+ // // Retrieve all stream entries
6790+ // res, err := client.XRevRangeWithOptions(
6791+ // "key",
6792+ // options.NewInfiniteStreamBoundary(options.PositiveInfinity),
6793+ // options.NewInfiniteStreamBoundary(options.NegativeInfinity),
6794+ // options.NewStreamRangeOptions().SetCount(10),
6795+ // )
6796+ // fmt.Println(res) // map[key:[["field2", "entry2"], ["field1", "entry1"]]]
6797+ //
6798+ // [valkey.io]: https://valkey.io/commands/xrevrange/
6799+ func (client * baseClient ) XRevRangeWithOptions (
6800+ key string ,
6801+ start options.StreamBoundary ,
6802+ end options.StreamBoundary ,
6803+ opts * options.StreamRangeOptions ,
6804+ ) (map [string ][][]string , error ) {
6805+ args := []string {key , string (start ), string (end )}
6806+ if opts != nil {
6807+ optionArgs , err := opts .ToArgs ()
6808+ if err != nil {
6809+ return nil , err
6810+ }
6811+ args = append (args , optionArgs ... )
6812+ }
6813+ result , err := client .executeCommand (C .XRevRange , args )
6814+ if err != nil {
6815+ return nil , err
6816+ }
6817+ return handleMapOfArrayOfStringArrayOrNilResponse (result )
6818+ }
0 commit comments