Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultExpiration is the default duration for items stored in // the cache to expire. DefaultExpiration time.Duration = 0 // ErrItemExpired is returned in Cache.Get when the item found in the cache // has expired. ErrItemExpired error = errors.InternalServer("ErrItemExpired", "item has expired") // ErrKeyNotFound is returned in Cache.Get and Cache.Delete when the // provided key could not be found in cache. ErrKeyNotFound error = errors.InternalServer("ErrKeyNotFound", "key not found in cache") )
View Source
var ( // DefaultCache is the default cache. DefaultCache cache.Cache = NewCache() )
Functions ¶
Types ¶
type Item ¶
type Item struct {
Value interface{}
Expiration int64
}
Item represents an item stored in the cache.
type Option ¶
type Option func(o *Options)
Option manipulates the Options passed.
func Expiration ¶
Expiration sets the duration for items stored in the cache to expire.
func WithAddress ¶
WithAddress sets the cache service address or connection information
func WithContext ¶
WithContext sets the cache context, for any extra configuration
type Options ¶
type Options struct {
Expiration time.Duration
Items map[string]Item
// Address represents the address or other connection information of the cache service.
Address string
// Context should contain all implementation specific options, using context.WithValue.
Context context.Context
}
Options represents the options for the cache.
Click to show internal directories.
Click to hide internal directories.