package dynacache
import "github.com/gohugoio/hugo/cache/dynacache"
Index ¶
- func CleanKey(s string) string
- type Cache
- func New(opts Options) *Cache
- func (c *Cache) ClearMatching(predicatePartition func(k string, p PartitionManager) bool, predicateValue func(k, v any) bool)
- func (c *Cache) ClearOnRebuild(predicate func(k, v any) bool, changeset ...identity.Identity)
- func (c *Cache) DrainEvictedIdentities() []KeyIdentity
- func (c *Cache) DrainEvictedIdentitiesMatching(predicate func(KeyIdentity) bool) []KeyIdentity
- func (c *Cache) Keys(predicate func(s string) bool) []string
- func (c *Cache) Stop()
- type ClearWhen
- type KeyIdentity
- type Options
- type OptionsPartition
- func (o OptionsPartition) CalculateMaxSize(maxSizePerPartition int) int
- func (o OptionsPartition) WeightFraction() float64
- type Partition
- func GetOrCreatePartition[K comparable, V any](c *Cache, name string, opts OptionsPartition) *Partition[K, V]
- func (p *Partition[K, V]) Clear()
- func (p *Partition[K, V]) Get(ctx context.Context, key K) (V, bool)
- func (p *Partition[K, V]) GetOrCreate(key K, create func(key K) (V, error)) (V, error)
- func (p *Partition[K, V]) GetOrCreateWitTimeout(key K, duration time.Duration, create func(key K) (V, error)) (V, error)
- func (p *Partition[K, V]) Keys() []K
- type PartitionManager
Functions ¶
func CleanKey ¶
CleanKey turns s into a format suitable for a cache key for this package. The key will be a Unix-styled path with a leading slash but no trailing slash.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
A dynamic partitioned cache.
func New ¶
New creates a new cache.
func (*Cache) ClearMatching ¶
func (c *Cache) ClearMatching(predicatePartition func(k string, p PartitionManager) bool, predicateValue func(k, v any) bool)
ClearMatching clears all partition for which the predicate returns true.
func (*Cache) ClearOnRebuild ¶
ClearOnRebuild prepares the cache for a new rebuild taking the given changeset into account. predicate is optional and will clear any entry for which it returns true.
func (*Cache) DrainEvictedIdentities ¶
func (c *Cache) DrainEvictedIdentities() []KeyIdentity
DrainEvictedIdentities drains the evicted identities from the cache.
func (*Cache) DrainEvictedIdentitiesMatching ¶
func (c *Cache) DrainEvictedIdentitiesMatching(predicate func(KeyIdentity) bool) []KeyIdentity
DrainEvictedIdentitiesMatching drains the evicted identities from the cache that match the given predicate.
func (*Cache) Keys ¶
Keys returns a list of keys in all partitions.
func (*Cache) Stop ¶
func (c *Cache) Stop()
Stop stops the cache.
type ClearWhen ¶
type ClearWhen int
type KeyIdentity ¶
type Options ¶
type Options struct { Log loggers.Logger CheckInterval time.Duration MaxSize int MinMaxSize int Watching bool }
Options for the cache.
type OptionsPartition ¶
type OptionsPartition struct { // When to clear the this partition. ClearWhen ClearWhen // Weight is a number between 1 and 100 that indicates how, in general, how big this partition may get. Weight int }
Options for a partition.
func (OptionsPartition) CalculateMaxSize ¶
func (o OptionsPartition) CalculateMaxSize(maxSizePerPartition int) int
func (OptionsPartition) WeightFraction ¶
func (o OptionsPartition) WeightFraction() float64
type Partition ¶
type Partition[K comparable, V any] struct { // contains filtered or unexported fields }
Partition is a partition in the cache.
func GetOrCreatePartition ¶
func GetOrCreatePartition[K comparable, V any](c *Cache, name string, opts OptionsPartition) *Partition[K, V]
GetOrCreatePartition gets or creates a partition with the given name.
func (*Partition[K, V]) Clear ¶
func (p *Partition[K, V]) Clear()
func (*Partition[K, V]) Get ¶
func (*Partition[K, V]) GetOrCreate ¶
GetOrCreate gets or creates a value for the given key.
func (*Partition[K, V]) GetOrCreateWitTimeout ¶
func (p *Partition[K, V]) GetOrCreateWitTimeout(key K, duration time.Duration, create func(key K) (V, error)) (V, error)
func (*Partition[K, V]) Keys ¶
func (p *Partition[K, V]) Keys() []K
type PartitionManager ¶
type PartitionManager interface {
// contains filtered or unexported methods
}
Source Files ¶
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 19 packages
- Last checked
- 13 hours ago –
Tools for package owners.