Redo settings a bit, move a lot of init logic to main.go
This commit is contained in:
6
cache/cache_redis.go
vendored
6
cache/cache_redis.go
vendored
@ -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) {
|
||||
|
Reference in New Issue
Block a user