@@ -6819,3 +6819,108 @@ func (client *baseClient) XRevRangeWithOptions(
68196819 }
68206820 return handleMapOfArrayOfStringArrayOrNilResponse (result )
68216821}
6822+
6823+ // Reads or modifies the array of bits representing the string that is held at key
6824+ // based on the specified sub commands.
6825+ //
6826+ // See [valkey.io] for details.
6827+ //
6828+ // Parameters:
6829+ //
6830+ // key - The key of the string.
6831+ // subCommands - The subCommands to be performed on the binary value of the string at
6832+ // key, which could be any of the following:
6833+ // - [BitFieldGet].
6834+ // - [BitFieldSet].
6835+ // - [BitFieldIncrby].
6836+ // - [BitFieldOverflow].
6837+ // Use `options.NewBitFieldGet()` to specify a BitField GET command.
6838+ // Use `options.NewBitFieldSet()` to specify a BitField SET command.
6839+ // Use `options.NewBitFieldIncrby()` to specify a BitField INCRYBY command.
6840+ // Use `options.BitFieldOverflow()` to specify a BitField OVERFLOW command.
6841+ //
6842+ // Return value:
6843+ //
6844+ // Result from the executed subcommands.
6845+ // - BitFieldGet returns the value in the binary representation of the string.
6846+ // - BitFieldSet returns the previous value before setting the new value in the binary representation.
6847+ // - BitFieldIncrBy returns the updated value after increasing or decreasing the bits.
6848+ // - BitFieldOverflow controls the behavior of subsequent operations and returns
6849+ // a result based on the specified overflow type (WRAP, SAT, FAIL).
6850+ //
6851+ // Example:
6852+ //
6853+ // commands := []options.BitFieldSubCommands{
6854+ // options.BitFieldGet(options.SignedInt, 8, 16),
6855+ // options.BitFieldOverflow(options.SAT),
6856+ // options.NewBitFieldSet(options.UnsignedInt, 4, 0, 7),
6857+ // options.BitFieldIncrBy(options.SignedInt, 5, 100, 1),
6858+ // }
6859+ // result, err := client.BitField("mykey", commands)
6860+ // result: [{0 false} {7 false} {15 false}]
6861+ //
6862+ // [valkey.io]: https://valkey.io/commands/bitfield/
6863+ func (client * baseClient ) BitField (key string , subCommands []options.BitFieldSubCommands ) ([]Result [int64 ], error ) {
6864+ args := make ([]string , 0 , 10 )
6865+ args = append (args , key )
6866+
6867+ for _ , cmd := range subCommands {
6868+ cmdArgs , err := cmd .ToArgs ()
6869+ if err != nil {
6870+ return nil , err
6871+ }
6872+ args = append (args , cmdArgs ... )
6873+ }
6874+
6875+ result , err := client .executeCommand (C .BitField , args )
6876+ if err != nil {
6877+ return nil , err
6878+ }
6879+ return handleIntOrNilArrayResponse (result )
6880+ }
6881+
6882+ // Reads the array of bits representing the string that is held at key
6883+ // based on the specified sub commands.
6884+ //
6885+ // See [valkey.io] for details.
6886+ //
6887+ // Parameters:
6888+ //
6889+ // key - The key of the string.
6890+ // subCommands - The read-only subCommands to be performed on the binary value
6891+ // of the string at key, which could be:
6892+ // - [BitFieldGet].
6893+ // Use `options.NewBitFieldGet()` to specify a BitField GET command.
6894+ //
6895+ // Return value:
6896+ //
6897+ // Result from the executed GET subcommands.
6898+ // - BitFieldGet returns the value in the binary representation of the string.
6899+ //
6900+ // Example:
6901+ //
6902+ // commands := []options.BitFieldROCommands{
6903+ // options.BitFieldGet(options.SignedInt, 8, 16),
6904+ // }
6905+ // result, err := client.BitFieldRO("mykey", commands)
6906+ // result: [{42 false}]
6907+ //
6908+ // [valkey.io]: https://valkey.io/commands/bitfield_ro/
6909+ func (client * baseClient ) BitFieldRO (key string , commands []options.BitFieldROCommands ) ([]Result [int64 ], error ) {
6910+ args := make ([]string , 0 , 10 )
6911+ args = append (args , key )
6912+
6913+ for _ , cmd := range commands {
6914+ cmdArgs , err := cmd .ToArgs ()
6915+ if err != nil {
6916+ return nil , err
6917+ }
6918+ args = append (args , cmdArgs ... )
6919+ }
6920+
6921+ result , err := client .executeCommand (C .BitFieldReadOnly , args )
6922+ if err != nil {
6923+ return nil , err
6924+ }
6925+ return handleIntOrNilArrayResponse (result )
6926+ }
0 commit comments