Documentation ¶
Index ¶
- func CleanKey(s string) string
- type Cache
- func (c *Cache) ClearMatching(predicatePartition func(k string, p PartitionManager) bool, ...)
- func (c *Cache) ClearOnRebuild(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
- type Partition
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
A dynamic partitioned 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.
func (*Cache) DrainEvictedIdentities ¶
func (c *Cache) DrainEvictedIdentities() []KeyIdentity
DrainEvictedIdentities drains the evicted identities from the cache.
func (*Cache) DrainEvictedIdentitiesMatching ¶ added in v0.128.0
func (c *Cache) DrainEvictedIdentitiesMatching(predicate func(KeyIdentity) bool) []KeyIdentity
DrainEvictedIdentitiesMatching drains the evicted identities from the cache that match the given predicate.
type KeyIdentity ¶ added in v0.128.0
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]) GetOrCreate ¶
GetOrCreate gets or creates a value for the given key.
func (*Partition[K, V]) GetOrCreateWitTimeout ¶
type PartitionManager ¶
type PartitionManager interface {
// contains filtered or unexported methods
}
Click to show internal directories.
Click to hide internal directories.