routecache

package
v0.0.0-...-32278fe Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package routecache is meant to assist in resolving the most used routes at an application. Implemented as a LRU, it returns always its full context for iteration at the router handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	MaxEntries int
	// contains filtered or unexported fields
}

Cache holds an internal linkedlist for hotness management. It is not safe for concurrent use, must be guarded externally.

func New

func New(maxentries int) *Cache

New returns a route cache.

func (*Cache) Delete

func (c *Cache) Delete(appname, path string)

Delete removes the element for the given appname and path from the cache.

func (*Cache) Get

func (c *Cache) Get(appname, path string) (route *models.Route, ok bool)

Get looks up a path's route from the cache.

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) Refresh

func (c *Cache) Refresh(route *models.Route)

Refresh updates internal linkedlist either adding a new route to the front, or moving it to the front when used. It will discard seldom used routes.

Jump to

Keyboard shortcuts

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