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:
parent
93c9f8a721
commit
90df18562c
1 changed files with 12 additions and 0 deletions
12
redis.go
12
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue