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

51 lines
1.1 KiB
Go

package content
import (
"container/list"
"time"
"github.com/foomo/neosproxy/cache/content/store"
"github.com/foomo/neosproxy/client/cms"
"github.com/foomo/neosproxy/logging"
"golang.org/x/sync/singleflight"
)
// Cache workspace items
type Cache struct {
observer Observer
loader cms.ContentLoader
store store.CacheStore
invalidationRequestGroup *singleflight.Group
invalidationChannel chan InvalidationRequest
invalidationRetryChannel chan InvalidationRequest
retryQueue *list.List
cacheDependencies *cacheDependencies
lifetime time.Duration // time until an item must be re-invalidated (< 0 === never)
log logging.Entry
}
// InvalidationRequest request VO
type InvalidationRequest struct {
ID string
Dimension string
Workspace string
CreatedAt time.Time
LastExecutedAt time.Time
ExecutionCounter int
}
// InvalidationResponse response VO
type InvalidationResponse struct {
Duration time.Duration
Item store.CacheItem
}
// Observer must be implemented by observers which are interested in update events
type Observer interface {
Notify(response InvalidationResponse)
}