cache

package
v0.0.0-...-f2271ba Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorized

type Authorized struct {
	sync.Mutex
	TTL   int
	Hosts map[string]time.Time
}

Authorized for storing Authorized DNS Hosts

func NewCache

func NewCache(ttl int) *Authorized

NewCache creates a new empty cache

func (*Authorized) Delete

func (c *Authorized) Delete(h string)

Delete (blocking) for deleting a host from cache

func (*Authorized) Exists

func (c *Authorized) Exists(h string) bool

Exists (blocking) returns true if a host is in cache

func (*Authorized) Expired

func (c *Authorized) Expired() []string

Expired (blocking) for returning all expired hosts. Returns empty slice if c.TTL is < 0

func (*Authorized) NewAuthMap

func (c *Authorized) NewAuthMap()

NewAuthMap replaces current cache.Hosts map with a new map by copying all the elements. We this to free up memory, since the allocated memory by cache.Hosts is that that the map had at its peak

func (*Authorized) Register

func (c *Authorized) Register(h string) bool

Register (blocking) for adding a new host to cache

func (*Authorized) Renew

func (c *Authorized) Renew(h string)

Renew (blocking) for updating a hosts registration time in cache

Jump to

Keyboard shortcuts

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