cache

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear added in v0.11.0

func Clear(t Type, prefix string) error

Clear clears all entries with the given prefix in the specified cache type

func Delete added in v0.11.0

func Delete(t Type, key string) error

Delete removes a value from the cache

func Get

func Get(t Type, key string, i any) (bool, error)

Get returns the cached value for a given key

func GetIPParseResult

func GetIPParseResult(ipStr string) (
	result model.IPParseResult, found bool,
	err error,
)

GetIPParseResult returns the cached result of an ip parsing

func InitCache added in v0.10.0

func InitCache()

InitCache initializes the cache according to the configuration

func Set

func Set(
	t Type, key string, value interface{},
	expiration ...time.Duration,
) error

Set sets a value in a cache

func SetCache added in v0.10.0

func SetCache(cache Cache)

SetCache sets the cache

func SetIPParseResult

func SetIPParseResult(ipStr string, ip model.IPParseResult) error

SetIPParseResult caches the result of an ip parsing

Types

type Cache added in v0.10.0

type Cache interface {
	Get(key string, target any) (bool, error)
	Set(key string, value any, expiration time.Duration) error
	Delete(key string) error
	Clear(prefix string) error
}

func NewInternalCache added in v0.10.0

func NewInternalCache(defaultExpiration time.Duration) Cache

func SubCache added in v0.10.0

func SubCache(t Type) Cache

SubCache returns a sub-cache for the given Type

type Type

type Type int

Type defines the type of cache

const (
	IPHostCache Type = iota

	WebProfiles
	FederationLib
	HealthcheckTest
	ScheduledNotifications
	IPCache
)

Different cache types

Jump to

Keyboard shortcuts

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