diff --git a/redis.go b/redis.go index c7d03b2..5187340 100644 --- a/redis.go +++ b/redis.go @@ -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) +}