Documentation ¶
Index ¶
- func CleanKey(s string) string
- type Cache
- type ClearWhen
- 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 ¶
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 ¶
DrainEvictedIdentities drains the evicted identities from the cache.
type Options ¶
type Options struct { Log loggers.Logger CheckInterval time.Duration MaxSize int MinMaxSize int Running 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.
type PartitionManager ¶
type PartitionManager interface {
// contains filtered or unexported methods
}
Click to show internal directories.
Click to hide internal directories.