1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

redis.go: implement functions for pipeline.

This commit is contained in:
Henrik Hautakoski 2022-01-20 11:49:13 +01:00
parent 93c9f8a721
commit 90df18562c
No known key found for this signature in database
GPG key ID: 608414D93E862CCD

View file

@ -10,6 +10,8 @@ import (
var rdb *redis.Client
var redis_pipe redis.Pipeliner
var redisCtx = context.Background()
var redisPrefix = "ship."
@ -20,6 +22,8 @@ func RedisConnect(addr string, password string, db int) {
Password: password,
DB: db,
})
redis_pipe = rdb.Pipeline()
}
func RedisKey(components ...string) (string) {
@ -37,3 +41,11 @@ func RedisSet(key string, value interface{}, expiration time.Duration) (*redis.S
func RedisPublish(channel string, message interface{}) (*redis.IntCmd) {
return rdb.Publish(redisCtx, channel, message)
}
func RedisRegisterPublish(channel string, message interface{}) (*redis.IntCmd) {
return redis_pipe.Publish(redisCtx, channel, message)
}
func RedisSend() ([]redis.Cmder, error) {
return redis_pipe.Exec(redisCtx)
}