Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultNormalizer = NewDefaultNormalizer()
DefaultNormalizer is a statically allocated default normalizer for strings.
Functions ¶
This section is empty.
Types ¶
type Normalizer ¶
type Normalizer[K comparable, V any] struct { // contains filtered or unexported fields }
Normalizer caches transformed results so we do not repeatedly transform the same inputs.
func NewDefaultNormalizer ¶
func NewDefaultNormalizer() *Normalizer[string, string]
NewDefaultNormalizer returns a normalizer using the default TTL and default transform (ToLower + TrimSpace).
func NewNormalizer ¶
func NewNormalizer[K comparable, V any](ttl time.Duration, transform TransformFunc[K, V]) *Normalizer[K, V]
NewNormalizer returns a normalizer with the provided TTL and transform function for cached entries.
func (*Normalizer[K, V]) Clear ¶
func (n *Normalizer[K, V]) Clear(key K)
Clear removes a cached entry.
func (*Normalizer[K, V]) Normalize ¶
func (n *Normalizer[K, V]) Normalize(key K) V
Normalize returns the transformed value.
type TransformFunc ¶
type TransformFunc[K, V any] func(K) V
TransformFunc is a function that transforms K to V.
Click to show internal directories.
Click to hide internal directories.