Documentation ¶
Overview ¶
Package cache implements a simple cache where the entries are expired after a given time (5 minutes of disuse by default).
Index ¶
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Entries() int
- func (c *Cache) Get(key string, create CreateFunc) (value interface{}, err error)
- func (c *Cache) GetMaybe(key string) (value interface{}, found bool)
- func (c *Cache) Pin(key string)
- func (c *Cache) Put(key string, value interface{})
- func (c *Cache) Rename(oldKey, newKey string) (value interface{}, found bool)
- func (c *Cache) Unpin(key string)
- type CreateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds values indexed by string, but expired after a given (5 minutes by default).
func (*Cache) Get ¶
func (c *Cache) Get(key string, create CreateFunc) (value interface{}, err error)
Get gets a value named key either from the cache or creates it afresh with the create function.
type CreateFunc ¶
CreateFunc is called to create new values. If the create function returns an error it will be cached if ok is true, otherwise the error will just be returned, allowing negative caching if required.
Click to show internal directories.
Click to hide internal directories.