From fb0ecce6c2b54a13a3762a348a461a7147a3cf72 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 28 Jun 2022 14:02:52 +0200 Subject: [PATCH] redis/wrapper.go: Adding XAdd() --- redis/wrapper.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/redis/wrapper.go b/redis/wrapper.go index 46c8ed3..09edea0 100644 --- a/redis/wrapper.go +++ b/redis/wrapper.go @@ -48,6 +48,18 @@ func Publish(channel string, message interface{}) (*_redis.IntCmd) { return rdb.Publish(redisCtx, channel, message) } +func XAdd(stream string, id string, maxlen int64, message map[string]interface{}) (*_redis.StringCmd) { + + args := &_redis.XAddArgs{ + Stream: stream, + ID: id, + MaxLenApprox: maxlen, + Values: message, + } + + return rdb.XAdd(redisCtx, args) +} + func RegisterPublish(channel string, message interface{}) (*_redis.IntCmd) { return redis_pipe.Publish(redisCtx, channel, message) }