@@ -194,6 +194,7 @@ type Cmdable interface {
194194 BitOpXor (ctx context.Context , destKey string , keys ... string ) * IntCmd
195195 BitOpNot (ctx context.Context , destKey string , key string ) * IntCmd
196196 BitPos (ctx context.Context , key string , bit int64 , pos ... int64 ) * IntCmd
197+ BitPosSpan (ctx context.Context , key string , bit int8 , start , end int64 , span string ) * IntCmd
197198 BitField (ctx context.Context , key string , args ... interface {}) * IntSliceCmd
198199
199200 Scan (ctx context.Context , cursor uint64 , match string , count int64 ) * ScanCmd
@@ -1211,6 +1212,8 @@ func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntC
12111212 return c .bitOp (ctx , "not" , destKey , key )
12121213}
12131214
1215+ // BitPos is an API before Redis version 7.0, cmd: bitpos key bit start end
1216+ // if you need the `byte | bit` parameter, please use `BitPosSpan`.
12141217func (c cmdable ) BitPos (ctx context.Context , key string , bit int64 , pos ... int64 ) * IntCmd {
12151218 args := make ([]interface {}, 3 + len (pos ))
12161219 args [0 ] = "bitpos"
@@ -1231,6 +1234,18 @@ func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64
12311234 return cmd
12321235}
12331236
1237+ // BitPosSpan supports the `byte | bit` parameters in redis version 7.0,
1238+ // the bitpos command defaults to using byte type for the `start-end` range,
1239+ // which means it counts in bytes from start to end. you can set the value
1240+ // of "span" to determine the type of `start-end`.
1241+ // span = "bit", cmd: bitpos key bit start end bit
1242+ // span = "byte", cmd: bitpos key bit start end byte
1243+ func (c cmdable ) BitPosSpan (ctx context.Context , key string , bit int8 , start , end int64 , span string ) * IntCmd {
1244+ cmd := NewIntCmd (ctx , "bitpos" , key , bit , start , end , span )
1245+ _ = c (ctx , cmd )
1246+ return cmd
1247+ }
1248+
12341249func (c cmdable ) BitField (ctx context.Context , key string , args ... interface {}) * IntSliceCmd {
12351250 a := make ([]interface {}, 0 , 2 + len (args ))
12361251 a = append (a , "bitfield" )
0 commit comments