diff --git a/bird/config.go b/bird/config.go index bfcdaed..03849a5 100644 --- a/bird/config.go +++ b/bird/config.go @@ -27,3 +27,10 @@ type RateLimitConfig struct { Max int `toml:"requests_per_minute"` Enabled bool } + +type CacheConfig struct { + UseRedis bool `toml:"use_redis"` + RedisServer string `toml:"redis_server"` + RedisPassword string `toml:"redis_password"` + RedisDb int `toml:"redis_db"` +} diff --git a/birdwatcher.go b/birdwatcher.go index 358b3d3..355dab9 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -97,6 +97,13 @@ func PrintServiceInfo(conf *Config, birdConf bird.BirdConfig) { log.Println(" AllowFrom:", strings.Join(conf.Server.AllowFrom, ", ")) } + if conf.Cache.UseRedis { + log.Println(" Caching backend: REDIS") + log.Println(" Using server:", conf.Cache.RedisServer) + } else { + log.Println(" Caching backend: MEMORY") + } + log.Println(" ModulesEnabled:") for _, m := range conf.Server.ModulesEnabled { log.Println(" -", m) @@ -133,6 +140,14 @@ func main() { bird.StatusConf = conf.Status bird.RateLimitConf.Conf = conf.Ratelimit bird.ParserConf = conf.Parser + + if conf.Cache.UseRedis { + bird.CacheRedis, err = bird.NewRedisCache(conf.Cache) + if err != nil { + log.Fatal("Could not initialize redis cache:", err) + } + } + endpoints.Conf = conf.Server // Make server