cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(logger *log.Entry, config *Configuration) (*Cache, error)

func (*Cache) AddUser

func (c *Cache) AddUser(user User) error

func (*Cache) GetUser

func (c *Cache) GetUser(username string, mac string) (User, bool)

func (*Cache) GetUserWithAge

func (c *Cache) GetUserWithAge(username string, mac string) (User, time.Duration, bool)

func (*Cache) GetUserWithRefreshNeed

func (c *Cache) GetUserWithRefreshNeed(username string, mac string) (User, bool, bool)

func (*Cache) HasUser

func (c *Cache) HasUser(username string, mac string) bool

func (*Cache) SetOffline

func (c *Cache) SetOffline()

func (*Cache) SetOnline

func (c *Cache) SetOnline()

func (*Cache) Status

func (c *Cache) Status() Status

type Configuration

type Configuration struct {
	MaxSize    int           `yaml:"size" default:"1000"`
	TTL        time.Duration `yaml:"ttl" default:"3h"`
	RefreshTTL time.Duration `yaml:"refresh_ttl" default:"1h"`
	OfflineTTL time.Duration `yaml:"offline_ttl"`
}

func (*Configuration) Check

func (c *Configuration) Check() error

type Status

type Status struct {
	Hits    int  `json:"hits"`
	Misses  int  `json:"misses"`
	Added   int  `json:"added"`
	Evicted int  `json:"evicted"`
	Entries int  `json:"entries"`
	Offline bool `json:"offline"`
}

Status provides statistics for cache

type User

type User struct {
	Username string
	Password string
	Mac      string
	VlanId   uint16
}

Jump to

Keyboard shortcuts

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