mirror of
https://github.com/foomo/neosproxy.git
synced 2026-11-30 00:31:46 +00:00
* feat: add test for filesystem caching * content cache dependencies cms content loader: context with timeout go builder version 1.13
51 lines
1.1 KiB
Go
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)
|
|
}
|