mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-18 04:40:03 +02:00
Formatting fix.
This commit is contained in:
parent
953113b456
commit
1e2dda54c8
9 changed files with 440 additions and 448 deletions
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
package redis
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"context"
|
||||
"time"
|
||||
_redis "github.com/go-redis/redis/v8"
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_redis "github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
var rdb *_redis.Client
|
||||
|
|
@ -17,41 +17,41 @@ var redisCtx = context.Background()
|
|||
var Prefix = "ship."
|
||||
|
||||
func Connect(addr string, password string, db int) error {
|
||||
rdb = _redis.NewClient(&_redis.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
DB: db,
|
||||
})
|
||||
rdb = _redis.NewClient(&_redis.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
DB: db,
|
||||
})
|
||||
|
||||
redis_pipe = rdb.Pipeline()
|
||||
redis_pipe = rdb.Pipeline()
|
||||
|
||||
return rdb.Ping(redisCtx).Err()
|
||||
return rdb.Ping(redisCtx).Err()
|
||||
}
|
||||
|
||||
func Client() *_redis.Client {
|
||||
return rdb
|
||||
return rdb
|
||||
}
|
||||
|
||||
func Key(components ...string) (string) {
|
||||
return Prefix + strings.Join(components, ".")
|
||||
func Key(components ...string) string {
|
||||
return Prefix + strings.Join(components, ".")
|
||||
}
|
||||
|
||||
func Get(key string) (*_redis.StringCmd) {
|
||||
return rdb.Get(redisCtx, key)
|
||||
func Get(key string) *_redis.StringCmd {
|
||||
return rdb.Get(redisCtx, key)
|
||||
}
|
||||
|
||||
func Set(key string, value interface{}, expiration time.Duration) (*_redis.StatusCmd) {
|
||||
return rdb.Set(redisCtx, key, value, expiration)
|
||||
func Set(key string, value interface{}, expiration time.Duration) *_redis.StatusCmd {
|
||||
return rdb.Set(redisCtx, key, value, expiration)
|
||||
}
|
||||
|
||||
func Publish(channel string, message interface{}) (*_redis.IntCmd) {
|
||||
return rdb.Publish(redisCtx, channel, message)
|
||||
func Publish(channel string, message interface{}) *_redis.IntCmd {
|
||||
return rdb.Publish(redisCtx, channel, message)
|
||||
}
|
||||
|
||||
func RegisterPublish(channel string, message interface{}) (*_redis.IntCmd) {
|
||||
return redis_pipe.Publish(redisCtx, channel, message)
|
||||
func RegisterPublish(channel string, message interface{}) *_redis.IntCmd {
|
||||
return redis_pipe.Publish(redisCtx, channel, message)
|
||||
}
|
||||
|
||||
func Send() ([]_redis.Cmder, error) {
|
||||
return redis_pipe.Exec(redisCtx)
|
||||
return redis_pipe.Exec(redisCtx)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue