Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Duration time.Duration // how long to cache data LastStats interface{} // holds the latest update (and the initial one). Updater UpdateFunc // returns the next update // contains filtered or unexported fields }
A Cache prevents too many API calls to expensive servers. It stores the latest update, and if subsequent calls to Update come before Duration, it returns the cached status update instead.
Set LastStats to an initial value with the type returned by the Updater. Cache panics if the types do not match.
type UpdateFunc ¶
type UpdateFunc func() (interface{}, error)
UpdateFunc is the signature of the updater function
Click to show internal directories.
Click to hide internal directories.