Documentation ¶
Overview ¶
The Tideland Go Library cache package provides a caching for individual lazy loaded values. The retrieval function and the timeout have to be specified.
Index ¶
Constants ¶
View Source
const (
ErrCannotRetrieve = iota + 1
)
Variables ¶
This section is empty.
Functions ¶
func PackageVersion ¶
PackageVersion returns the version of the version package.
Types ¶
type CachedValue ¶
type CachedValue interface { // Value returns the cached value. If an error occurred // during retrieval that will be returned too. Value() (v interface{}, err error) // Clear clears the cached value so that it will be // retrieved again when Value() is called the next time. Clear() // Remove removes this cached value from the cache. Remove() }
func NewCachedValue ¶
func NewCachedValue(r RetrievalFunc, ttl time.Duration) CachedValue
NewCachedValue creates a new cache. The retrieval func is responsible for the retrieval of the value while ttl defines how long the value is valid.
type RetrievalFunc ¶
type RetrievalFunc func() (interface{}, error)
RetrievalFunc is the signature of a function responsible for the retrieval of the cached value from somewhere else in the system, e.g. a database.
Click to show internal directories.
Click to hide internal directories.