cache

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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
}

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
	FederationOPMetadata
	ScheduledNotifications
	IPCache
)

Different cache types

Jump to

Keyboard shortcuts

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