Files
Frederik Löffert ceb8106914 feature/cache dependencies (#5)
* feat: add test for filesystem caching

* content cache dependencies
cms content loader: context with timeout
go builder version 1.13
2019-10-22 11:14:19 +02:00

48 lines
1.1 KiB
Go

package cache
import (
"time"
"github.com/foomo/neosproxy/logging"
)
func (c *Cache) scheduleInvalidation() {
skipped := 0
// logger
log := logging.GetDefaultLogEntry().WithField(logging.FieldWorkspace, c.Workspace)
for {
select {
case requestTime := <-c.invalidationChannel:
log.Info("handle invalidation request from queue")
time.Sleep(invalidationSleepTime)
if len(c.invalidationChannel) > 0 && skipped < maxSkipInvalidations {
skipped++
log.Info("skip invalidation due to more requests in queue")
continue
}
skipped = 0
if errInvalidation := c.cacheNeosContentServerExport(); errInvalidation != nil {
if errInvalidation == ErrorNoNewExort {
log.WithDuration(requestTime).Info("contentserver export cache invalidation request processed - but export hash matches old one")
continue
}
log.WithError(errInvalidation).Error("cache invalidation failed")
continue
}
// @todo: notify observers
log.WithDuration(requestTime).Info("contentserver export cache invalidation request processed")
}
}
}