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 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
Click to show internal directories.
Click to hide internal directories.