Documentation
¶
Overview ¶
Package caching providers a scalable cache component.
Index ¶
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 represents a cache manager.
func MustNewCache ¶
MustNewCache is like as NewCache but panic if container is nil.
func (*Cache) Get ¶
Get returns the cache item by given key. It returns nil if cache item has expired or not found.
func (*Cache) SetContainer ¶
SetContainer sets the container for cache.
type Container ¶
type Container interface { // Clear removes all items. Clear() error // Remove removes the item by given key. Remove(key string) error // Put inserts/updates the item. Put(item *Item) error // Get returns the value by given key. Get(key string) (*Item, error) }
Container represents a cache container.
type Dependency ¶
type Dependency interface { // HasChanged reports whehter dependency has changed. HasChanged() bool }
Dependency represents an external cache dependency.
type Item ¶
type Item struct { Key string Value interface{} CreatedAt time.Time AccessedAt time.Time AbsoluteExpirationTime time.Time SlidingExpirationPeriod time.Duration Dependencies []Dependency }
Item represents a cache item.
func MustNewItem ¶
MustNewItem is like as NewItem but panic if key is empty.
func (*Item) HasExpired ¶
HasExpired reports whether the item has expired.
func (*Item) SetAbsoluteExpiration ¶
SetAbsoluteExpiration sets the Absolute expiration for item.
func (*Item) SetDependencies ¶
func (i *Item) SetDependencies(Dependencies ...Dependency)
SetDependencies sets the Dependencies for item.
func (*Item) SetSlidingExpiration ¶
SetSlidingExpiration sets the Sliding expiration for item.
Directories
¶
Path | Synopsis |
---|---|
container
|
|
concurrent
Package concurrent providers a cache container wrapper for safe concurrent access.
|
Package concurrent providers a cache container wrapper for safe concurrent access. |
memory
Package memory providers in-memory cache containers.
|
Package memory providers in-memory cache containers. |
memory/arc
Package arc providers an in-memory cache container using ARC (adaptive/adjustable replacement cache) arithmetic.
|
Package arc providers an in-memory cache container using ARC (adaptive/adjustable replacement cache) arithmetic. |
memory/fifo
Package fifo providers an in-memory cache container using FIFO (first in first out) arithmetic.
|
Package fifo providers an in-memory cache container using FIFO (first in first out) arithmetic. |
memory/lfu
Package lfu providers an in-memory cache container using LFU (least frequently used) arithmetic.
|
Package lfu providers an in-memory cache container using LFU (least frequently used) arithmetic. |
memory/lru
Package lru providers an in-memory cache Container using LRU (least recently used) arithmetic.
|
Package lru providers an in-memory cache Container using LRU (least recently used) arithmetic. |
memory/mru
Package mru providers an in-memory cache Container using MRU (most recently used) arithmetic.
|
Package mru providers an in-memory cache Container using MRU (most recently used) arithmetic. |
multilevel
Package multilevel providers a cache container wrapper for wrapping multi-level containers.
|
Package multilevel providers a cache container wrapper for wrapping multi-level containers. |
dependency
|
|
file
Package file providers a file caching dependency.
|
Package file providers a file caching dependency. |