cache: add negative cache; router: skip race for cached 404s
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ibeb44b313850395898bb20f2d947b0b76a6a6964
This commit is contained in:
parent
f100342720
commit
b0ea022dc2
7 changed files with 147 additions and 4 deletions
|
|
@ -52,6 +52,7 @@ type CacheConfig struct {
|
|||
DBPath string `yaml:"db_path"`
|
||||
MaxEntries int `yaml:"max_entries"`
|
||||
TTL Duration `yaml:"ttl"`
|
||||
NegativeTTL Duration `yaml:"negative_ttl"`
|
||||
LatencyAlpha float64 `yaml:"latency_alpha"`
|
||||
}
|
||||
|
||||
|
|
@ -96,6 +97,7 @@ func defaults() Config {
|
|||
DBPath: "/var/lib/ncro/routes.db",
|
||||
MaxEntries: 100000,
|
||||
TTL: Duration{time.Hour},
|
||||
NegativeTTL: Duration{10 * time.Minute},
|
||||
LatencyAlpha: 0.3,
|
||||
},
|
||||
Mesh: MeshConfig{
|
||||
|
|
@ -134,6 +136,9 @@ func (c *Config) Validate() error {
|
|||
if c.Cache.TTL.Duration <= 0 {
|
||||
return fmt.Errorf("cache.ttl must be positive")
|
||||
}
|
||||
if c.Cache.NegativeTTL.Duration <= 0 {
|
||||
return fmt.Errorf("cache.negative_ttl must be positive")
|
||||
}
|
||||
if c.Cache.MaxEntries <= 0 {
|
||||
return fmt.Errorf("cache.max_entries must be positive")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue