-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.go
More file actions
46 lines (36 loc) · 1.51 KB
/
stream.go
File metadata and controls
46 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package redisdk
import (
"context"
"time"
"github.com/redis/go-redis/v9"
)
func XAdd(stream string, values any) (string, error) {
return universalClient.XAdd(context.Background(), &redis.XAddArgs{Stream: stream, Values: values}).Result()
}
func XAddValues(stream string, values any) (string, error) {
return universalClient.XAdd(context.Background(), &redis.XAddArgs{Stream: stream, Values: values, NoMkStream: true}).Result()
}
func XDel(stream string, ids ...string) (int64, error) {
return universalClient.XDel(context.Background(), stream, ids...).Result()
}
func XGroupCreateMkStream(stream string, group string) (string, error) {
return universalClient.XGroupCreateMkStream(context.Background(), stream, group, "$").Result()
}
func XGroupDestroy(stream string, group string) (int64, error) {
return universalClient.XGroupDestroy(context.Background(), stream, group).Result()
}
func XReadGroup(stream string, group string, consumer string, block time.Duration, count int64) ([]redis.XStream, error) {
return universalClient.XReadGroup(context.Background(), &redis.XReadGroupArgs{
Group: group,
Consumer: consumer,
Streams: []string{stream, ">"},
Block: block,
Count: count,
}).Result()
}
func XTrimMaxLen(stream string, maxLen int64) (int64, error) {
return universalClient.XTrimMaxLen(context.Background(), stream, maxLen).Result()
}
func XAck(stream string, group string, messageId string) (int64, error) {
return universalClient.XAck(context.Background(), stream, group, messageId).Result()
}