Redo settings a bit, move a lot of init logic to main.go

This commit is contained in:
Tyler
2020-01-25 13:48:26 -05:00
parent 991ae3ecb5
commit f726a5d5ae
12 changed files with 152 additions and 394 deletions

View File

@ -7,7 +7,7 @@ import (
"time"
)
func NewRedisCache(c settings.RedisSettings, expire int32) *RedisCache {
func NewRedisCache(c settings.RedisSettings, expire time.Duration) *RedisCache {
rc := redis.NewClient(&redis.Options{Addr: c.Addr(), DB: c.DB, Password: c.Password})
return &RedisCache{
@ -20,7 +20,7 @@ type RedisCache struct {
Cache
backend *redis.Client
expire int32
expire time.Duration
}
func (m *RedisCache) Set(key string, msg *dns.Msg) error {
@ -38,7 +38,7 @@ func (m *RedisCache) Set(key string, msg *dns.Msg) error {
if err != nil {
err = SerializerError{err}
}
return m.backend.Set(key, val, time.Duration(m.expire) * time.Second).Err()
return m.backend.Set(key, val, m.expire).Err()
}
func (m *RedisCache) Get(key string) (*dns.Msg, error) {