@@ -2,12 +2,15 @@ package redis
2
2
3
3
import (
4
4
"context"
5
+ "strconv"
5
6
"time"
6
7
)
7
8
8
9
type StreamCmdable interface {
9
10
XAdd (ctx context.Context , a * XAddArgs ) * StringCmd
11
+ XAckDel (ctx context.Context , stream string , group string , mode string , ids ... string ) * IntCmd
10
12
XDel (ctx context.Context , stream string , ids ... string ) * IntCmd
13
+ XDelEx (ctx context.Context , stream string , mode string , ids ... string ) * IntCmd
11
14
XLen (ctx context.Context , stream string ) * IntCmd
12
15
XRange (ctx context.Context , stream , start , stop string ) * XMessageSliceCmd
13
16
XRangeN (ctx context.Context , stream , start , stop string , count int64 ) * XMessageSliceCmd
@@ -31,8 +34,12 @@ type StreamCmdable interface {
31
34
XAutoClaimJustID (ctx context.Context , a * XAutoClaimArgs ) * XAutoClaimJustIDCmd
32
35
XTrimMaxLen (ctx context.Context , key string , maxLen int64 ) * IntCmd
33
36
XTrimMaxLenApprox (ctx context.Context , key string , maxLen , limit int64 ) * IntCmd
37
+ XTrimMaxLenMode (ctx context.Context , key string , maxLen int64 , mode string ) * IntCmd
38
+ XTrimMaxLenApproxMode (ctx context.Context , key string , maxLen , limit int64 , mode string ) * IntCmd
34
39
XTrimMinID (ctx context.Context , key string , minID string ) * IntCmd
35
40
XTrimMinIDApprox (ctx context.Context , key string , minID string , limit int64 ) * IntCmd
41
+ XTrimMinIDMode (ctx context.Context , key string , minID string , mode string ) * IntCmd
42
+ XTrimMinIDApproxMode (ctx context.Context , key string , minID string , limit int64 , mode string ) * IntCmd
36
43
XInfoGroups (ctx context.Context , key string ) * XInfoGroupsCmd
37
44
XInfoStream (ctx context.Context , key string ) * XInfoStreamCmd
38
45
XInfoStreamFull (ctx context.Context , key string , count int ) * XInfoStreamFullCmd
@@ -54,6 +61,7 @@ type XAddArgs struct {
54
61
// Approx causes MaxLen and MinID to use "~" matcher (instead of "=").
55
62
Approx bool
56
63
Limit int64
64
+ Mode string
57
65
ID string
58
66
Values interface {}
59
67
}
@@ -81,6 +89,11 @@ func (c cmdable) XAdd(ctx context.Context, a *XAddArgs) *StringCmd {
81
89
if a .Limit > 0 {
82
90
args = append (args , "limit" , a .Limit )
83
91
}
92
+
93
+ if a .Mode != "" {
94
+ args = append (args , a .Mode )
95
+ }
96
+
84
97
if a .ID != "" {
85
98
args = append (args , a .ID )
86
99
} else {
@@ -93,6 +106,16 @@ func (c cmdable) XAdd(ctx context.Context, a *XAddArgs) *StringCmd {
93
106
return cmd
94
107
}
95
108
109
+ func (c cmdable ) XAckDel (ctx context.Context , stream string , group string , mode string , ids ... string ) * IntCmd {
110
+ args := []interface {}{"xdelex" , stream , group , mode , "ids" , strconv .Itoa (len (ids ))}
111
+ for _ , id := range ids {
112
+ args = append (args , id )
113
+ }
114
+ cmd := NewIntCmd (ctx , args ... )
115
+ _ = c (ctx , cmd )
116
+ return cmd
117
+ }
118
+
96
119
func (c cmdable ) XDel (ctx context.Context , stream string , ids ... string ) * IntCmd {
97
120
args := []interface {}{"xdel" , stream }
98
121
for _ , id := range ids {
@@ -103,6 +126,16 @@ func (c cmdable) XDel(ctx context.Context, stream string, ids ...string) *IntCmd
103
126
return cmd
104
127
}
105
128
129
+ func (c cmdable ) XDelEx (ctx context.Context , stream string , mode string , ids ... string ) * IntCmd {
130
+ args := []interface {}{"xdelex" , stream , mode , "ids" , strconv .Itoa (len (ids ))}
131
+ for _ , id := range ids {
132
+ args = append (args , id )
133
+ }
134
+ cmd := NewIntCmd (ctx , args ... )
135
+ _ = c (ctx , cmd )
136
+ return cmd
137
+ }
138
+
106
139
func (c cmdable ) XLen (ctx context.Context , stream string ) * IntCmd {
107
140
cmd := NewIntCmd (ctx , "xlen" , stream )
108
141
_ = c (ctx , cmd )
@@ -418,6 +451,42 @@ func (c cmdable) XTrimMinIDApprox(ctx context.Context, key string, minID string,
418
451
return c .xTrim (ctx , key , "minid" , true , minID , limit )
419
452
}
420
453
454
+ func (c cmdable ) xTrimMode (
455
+ ctx context.Context , key , strategy string ,
456
+ approx bool , threshold interface {}, limit int64 ,
457
+ mode string ,
458
+ ) * IntCmd {
459
+ args := make ([]interface {}, 0 , 7 )
460
+ args = append (args , "xtrim" , key , strategy )
461
+ if approx {
462
+ args = append (args , "~" )
463
+ }
464
+ args = append (args , threshold )
465
+ if limit > 0 {
466
+ args = append (args , "limit" , limit )
467
+ }
468
+ args = append (args , mode )
469
+ cmd := NewIntCmd (ctx , args ... )
470
+ _ = c (ctx , cmd )
471
+ return cmd
472
+ }
473
+
474
+ func (c cmdable ) XTrimMaxLenMode (ctx context.Context , key string , maxLen int64 , mode string ) * IntCmd {
475
+ return c .xTrimMode (ctx , key , "maxlen" , false , maxLen , 0 , mode )
476
+ }
477
+
478
+ func (c cmdable ) XTrimMaxLenApproxMode (ctx context.Context , key string , maxLen , limit int64 , mode string ) * IntCmd {
479
+ return c .xTrimMode (ctx , key , "maxlen" , true , maxLen , limit , mode )
480
+ }
481
+
482
+ func (c cmdable ) XTrimMinIDMode (ctx context.Context , key string , minID string , mode string ) * IntCmd {
483
+ return c .xTrimMode (ctx , key , "minid" , false , minID , 0 , mode )
484
+ }
485
+
486
+ func (c cmdable ) XTrimMinIDApproxMode (ctx context.Context , key string , minID string , limit int64 , mode string ) * IntCmd {
487
+ return c .xTrimMode (ctx , key , "minid" , true , minID , limit , mode )
488
+ }
489
+
421
490
func (c cmdable ) XInfoConsumers (ctx context.Context , key string , group string ) * XInfoConsumersCmd {
422
491
cmd := NewXInfoConsumersCmd (ctx , key , group )
423
492
_ = c (ctx , cmd )
0 commit comments