mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 21:51:02 +03:00
parent
8731d88222
commit
6cd0784e44
33 changed files with 1033 additions and 148 deletions
18
cache/dynacache/dynacache.go
vendored
18
cache/dynacache/dynacache.go
vendored
|
@ -38,6 +38,11 @@ import (
|
|||
|
||||
const minMaxSize = 10
|
||||
|
||||
type KeyIdentity struct {
|
||||
Key any
|
||||
Identity identity.Identity
|
||||
}
|
||||
|
||||
// New creates a new cache.
|
||||
func New(opts Options) *Cache {
|
||||
if opts.CheckInterval == 0 {
|
||||
|
@ -64,14 +69,14 @@ func New(opts Options) *Cache {
|
|||
|
||||
infol := opts.Log.InfoCommand("dynacache")
|
||||
|
||||
evictedIdentities := collections.NewStack[identity.Identity]()
|
||||
evictedIdentities := collections.NewStack[KeyIdentity]()
|
||||
|
||||
onEvict := func(k, v any) {
|
||||
if !opts.Watching {
|
||||
return
|
||||
}
|
||||
identity.WalkIdentitiesShallow(v, func(level int, id identity.Identity) bool {
|
||||
evictedIdentities.Push(id)
|
||||
evictedIdentities.Push(KeyIdentity{Key: k, Identity: id})
|
||||
return false
|
||||
})
|
||||
resource.MarkStale(v)
|
||||
|
@ -124,7 +129,7 @@ type Cache struct {
|
|||
partitions map[string]PartitionManager
|
||||
|
||||
onEvict func(k, v any)
|
||||
evictedIdentities *collections.Stack[identity.Identity]
|
||||
evictedIdentities *collections.Stack[KeyIdentity]
|
||||
|
||||
opts Options
|
||||
infol logg.LevelLogger
|
||||
|
@ -135,10 +140,15 @@ type Cache struct {
|
|||
}
|
||||
|
||||
// DrainEvictedIdentities drains the evicted identities from the cache.
|
||||
func (c *Cache) DrainEvictedIdentities() []identity.Identity {
|
||||
func (c *Cache) DrainEvictedIdentities() []KeyIdentity {
|
||||
return c.evictedIdentities.Drain()
|
||||
}
|
||||
|
||||
// DrainEvictedIdentitiesMatching drains the evicted identities from the cache that match the given predicate.
|
||||
func (c *Cache) DrainEvictedIdentitiesMatching(predicate func(KeyIdentity) bool) []KeyIdentity {
|
||||
return c.evictedIdentities.DrainMatching(predicate)
|
||||
}
|
||||
|
||||
// ClearMatching clears all partition for which the predicate returns true.
|
||||
func (c *Cache) ClearMatching(predicatePartition func(k string, p PartitionManager) bool, predicateValue func(k, v any) bool) {
|
||||
if predicatePartition == nil {
|
||||
|
|
1
cache/httpcache/httpcache.go
vendored
1
cache/httpcache/httpcache.go
vendored
|
@ -83,7 +83,6 @@ func (c *Config) Compile() (ConfigCompiled, error) {
|
|||
}
|
||||
|
||||
// PollConfig holds the configuration for polling remote resources to detect changes in watch mode.
|
||||
// TODO1 make sure this enabled only in watch mode.
|
||||
type PollConfig struct {
|
||||
// What remote resources to apply this configuration to.
|
||||
For GlobMatcher
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue