mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
use redis cache if configured
This commit is contained in:
parent
8552547afa
commit
15f2561c87
2 changed files with 22 additions and 0 deletions
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue