stringcache

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainedGroupedCache

type ChainedGroupedCache struct {
	// contains filtered or unexported fields
}

func NewChainedGroupedCache

func NewChainedGroupedCache(caches ...GroupedStringCache) *ChainedGroupedCache

func (*ChainedGroupedCache) Contains

func (c *ChainedGroupedCache) Contains(searchString string, groups []string) map[string]string

func (*ChainedGroupedCache) ElementCount

func (c *ChainedGroupedCache) ElementCount(group string) int

func (*ChainedGroupedCache) Refresh

func (c *ChainedGroupedCache) Refresh(group string) GroupFactory

type GroupFactory

type GroupFactory interface {
	// AddEntry adds a new string to the factory to be added later to the cache groups.
	AddEntry(entry string) bool

	// Count returns amount of processed string in the factory
	Count() int

	// Finish replaces the group in cache with factory's content
	Finish()
}

type GroupedStringCache

type GroupedStringCache interface {
	// Contains checks if one or more groups in the cache contains the search string.
	// Returns a map of matching group -> the rule that matched, or nil/empty when
	// the string was not found.
	//
	// The returned map must be freshly allocated and owned by the caller: callers
	// (e.g. ChainedGroupedCache) may retain and mutate it. Implementations must not
	// return a retained, shared, or pooled map.
	Contains(searchString string, groups []string) map[string]string

	// Refresh creates new factory for the group to be refreshed.
	// Calling Finish on the factory will perform the group refresh.
	Refresh(group string) GroupFactory

	// ElementCount returns the amount of elements in the group
	ElementCount(group string) int
}

type InMemoryGroupedCache

type InMemoryGroupedCache struct {
	// contains filtered or unexported fields
}

InMemoryGroupedCache holds one stringCache per group. The group map only changes on list refresh, while it is read on every query, so it is kept behind an atomic.Pointer and replaced copy-on-write: lookups are a single lock-free atomic load with no per-group locking, and refreshes (serialised by writeLock) swap in a fresh map. This avoids the reader-count cache-line contention an RWMutex would incur across in-flight requests.

func NewInMemoryGroupedRegexCache

func NewInMemoryGroupedRegexCache() *InMemoryGroupedCache

func NewInMemoryGroupedStringCache

func NewInMemoryGroupedStringCache() *InMemoryGroupedCache

func NewInMemoryGroupedWildcardCache

func NewInMemoryGroupedWildcardCache() *InMemoryGroupedCache

func (*InMemoryGroupedCache) Contains

func (c *InMemoryGroupedCache) Contains(searchString string, groups []string) map[string]string

func (*InMemoryGroupedCache) ElementCount

func (c *InMemoryGroupedCache) ElementCount(group string) int

func (*InMemoryGroupedCache) Refresh

func (c *InMemoryGroupedCache) Refresh(group string) GroupFactory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL