base

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the key is not found.

Functions

func GetExpireAt

func GetExpireAt(ttl int) time.Time

GetExpireAt returns the expiration time.

Types

type Cache

type Cache interface {
	// Load loads the cache
	Load(data map[string]CacheValue) error

	// Get returns the value for the given key
	Get(domain string) ([]dns.RR, error)

	// GetAll returns all the values in the cache
	GetAll() map[string]CacheValue

	// Set sets the value for the given key
	Set(domain string, value []dns.RR) error

	// Delete deletes the value for the given key
	Delete(key string) error

	// Clear clears the cache
	Clear() error

	// Close closes the cache
	Close() error

	// Len returns the number of items in the cache
	Len() int

	// Keys returns the keys in the cache
	Keys() []string

	// Exists returns true if the key exists
	Exists(domain string) bool

	// HasExpired returns true if the key has expired
	HasExpired(domain string) bool

	// GetExpireAt returns the expiration time
	GetExpireAt(domain string) time.Time
}

type CacheValue

type CacheValue struct {
	Value    []dns.RR
	ExpireAt time.Time
}

Jump to

Keyboard shortcuts

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