@@ -194,6 +194,7 @@ type Cmdable interface {
194
194
BitOpXor (ctx context.Context , destKey string , keys ... string ) * IntCmd
195
195
BitOpNot (ctx context.Context , destKey string , key string ) * IntCmd
196
196
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
197
198
BitField (ctx context.Context , key string , args ... interface {}) * IntSliceCmd
198
199
199
200
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
1211
1212
return c .bitOp (ctx , "not" , destKey , key )
1212
1213
}
1213
1214
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`.
1214
1217
func (c cmdable ) BitPos (ctx context.Context , key string , bit int64 , pos ... int64 ) * IntCmd {
1215
1218
args := make ([]interface {}, 3 + len (pos ))
1216
1219
args [0 ] = "bitpos"
@@ -1231,6 +1234,18 @@ func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64
1231
1234
return cmd
1232
1235
}
1233
1236
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
+
1234
1249
func (c cmdable ) BitField (ctx context.Context , key string , args ... interface {}) * IntSliceCmd {
1235
1250
a := make ([]interface {}, 0 , 2 + len (args ))
1236
1251
a = append (a , "bitfield" )
0 commit comments