2017-06-30 18:40:25 +03:00
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"elyby/minecraft-skinsystem/model"
|
|
|
|
|
|
|
|
"github.com/mediocregopher/radix.v2/pool"
|
|
|
|
)
|
|
|
|
|
2017-07-02 03:35:38 +03:00
|
|
|
type RedisSkinsFactory struct {
|
2017-06-30 18:40:25 +03:00
|
|
|
Addr string
|
|
|
|
PollSize int
|
|
|
|
}
|
|
|
|
|
2017-07-02 03:35:38 +03:00
|
|
|
func (cfg *RedisSkinsFactory) Create() (model.SkinsRepository, error) {
|
2017-06-30 18:40:25 +03:00
|
|
|
conn, err := pool.New("tcp", cfg.Addr, cfg.PollSize)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: здесь можно запустить горутину по восстановлению соединения
|
|
|
|
|
2017-07-02 03:35:38 +03:00
|
|
|
return &redisDb{conn: conn}, nil
|
2017-06-30 18:40:25 +03:00
|
|
|
}
|