domain

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v0.12.0

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

Cache provides a means of caching domains in memory to reduce load on an underlying storage mechanism, e.g. a database.

The in-memory domain list is kept up-to-date by means of a passed loader function during every call to .Matches(). In the case of a nil internal domain list, the loader function is called to hydrate the cache with the latest list of domains.

The .Clear() function can be used to invalidate the cache, e.g. when an entry is added / deleted from the database.

func (*Cache) Clear added in v0.12.0

func (c *Cache) Clear()

Clear will drop the currently loaded domain list, triggering a reload on next call to .Matches().

func (*Cache) Matches added in v0.12.0

func (c *Cache) Matches(domain string, load func() ([]string, error)) (bool, error)

Matches checks whether domain matches an entry in the cache. If the cache is not currently loaded, then the provided load function is used to hydrate it.

func (*Cache) String added in v0.12.0

func (c *Cache) String() string

String returns a string representation of stored domains in cache.

Jump to

Keyboard shortcuts

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