27 lines
546 B
Go
27 lines
546 B
Go
package redis
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.darwincereska.dev/darwincereska/meld/internal/models"
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
type Pool struct {
|
|
client *redis.Client
|
|
}
|
|
|
|
// Create a new Redis client
|
|
func InitRedis(address string, poolSize int) *Pool {
|
|
rdb := redis.NewClient(&redis.Options{
|
|
Addr: address,
|
|
PoolSize: poolSize,
|
|
})
|
|
|
|
return &Pool{client: rdb}
|
|
}
|
|
|
|
func (p *Pool) Add(ctx context.Context, key string, ticket models.Ticket) error {
|
|
return p.client.ZAdd(ctx, "matchmaking:"+key, redis.Z{Member: ticket.PlayerID}).Err()
|
|
}
|