cache

package
v0.0.0-...-646a310 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2014 License: MIT Imports: 5 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 {
	GetValue   func() interface{}
	Delay      time.Duration
	NextUpdate time.Time

	sync.RWMutex
	// contains filtered or unexported fields
}

Cache implements a thread-safe cache for polling resources.

func HTTPResponse

func HTTPResponse(rq *http.Request, process func(b []byte) interface{}, client *http.Client, t time.Duration) *Cache

HTTPResponse is a convenience function that makes the http request rq periodically and processes the response with 'process'.

func New

func New(get func() interface{}, delay time.Duration) (c *Cache)

func (*Cache) Get

func (c *Cache) Get() interface{}

Returns a Response with the current value of the Cache as an interface{}.

func (*Cache) Value

func (c *Cache) Value() Response

Returns a Response with the current value of the Cache.

type Response

type Response struct {
	Value interface{}
	Stale bool
	Error error
}

Jump to

Keyboard shortcuts

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