Documentation
¶
Index ¶
Constants ¶
View Source
const ( Prod = "prod" Dev = "dev" Test = "test" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheBox ¶
type CacheBox struct {
Env string `yaml:"env"`
Enabled bool `yaml:"enabled"`
Logs Logs `yaml:"logs"`
ForceGC ForceGC `yaml:"forceGC"`
LifeTime Lifetime `yaml:"lifetime"`
Upstream Upstream `yaml:"upstream"`
Persistence Persistence `yaml:"persistence"`
Preallocate Preallocation `yaml:"preallocate"`
Eviction Eviction `yaml:"eviction"`
Refresh Refresh `yaml:"refresh"`
Storage Storage `yaml:"storage"`
Rules map[string]*Rule `yaml:"rules"`
}
type Persistence ¶
type Persistence struct {
Dump Dump `yaml:"dump"`
}
type Preallocation ¶
type Preallocation struct {
PerShard int `yaml:"per_shard"`
}
type Refresh ¶
type Refresh struct {
Enabled bool `yaml:"enabled"`
// TTL - refresh TTL (max time life of response item in cache without refreshing).
TTL time.Duration `yaml:"ttl"` // e.g. "1d" (responses with 200 status code)
// ErrorTTL - error refresh TTL (max time life of response item with non 200 status code in cache without refreshing).
ErrorTTL time.Duration `yaml:"error_ttl"` // e.g. "1h" (responses with non 200 status code)
Rate int `yaml:"rate"` // Rate limiting to external backend.
ScanRate int `yaml:"scan_rate"` // Rate limiting of num scans items per second.
// beta определяет коэффициент, используемый для вычисления случайного момента обновления кэша.
// Чем выше beta, тем чаще кэш будет обновляться до истечения TTL.
// Формула взята из подхода "stochastic cache expiration" (см. Google Staleness paper):
// expireTime = ttl * (-beta * ln(random()))
// Подробнее: RFC 5861 и https://web.archive.org/web/20100829170210/http://labs.google.com/papers/staleness.pdf
// beta: "0.4"
Beta float64 `yaml:"beta"` // between 0 and 1
MinStale time.Duration // computed=time.Duration(float64(TTL/ErrorTTL) * Beta)
}
type Rule ¶
type Rule struct {
Gzip Gzip `yaml:"gzip"`
PathBytes []byte
TTL time.Duration `yaml:"ttl"` // TTL for this rule.
ErrorTTL time.Duration `yaml:"error_ttl"` // ErrorTTL for this rule.
Beta float64 `yaml:"beta"` // between 0 and 1
CacheKey Key `yaml:"cache_key"`
CacheValue Value `yaml:"cache_value"`
MinStale time.Duration // computed=time.Duration(float64(TTL/ErrorTTL) * Beta)
}
Click to show internal directories.
Click to hide internal directories.