Documentation ¶
Index ¶
- type Cache
- type GoCache
- func (gc *GoCache) Add(key []byte, value interface{}) error
- func (gc *GoCache) AddWithExpiration(key []byte, value interface{}, expiration time.Duration) error
- func (gc *GoCache) Get(key []byte) (interface{}, bool)
- func (gc *GoCache) Set(key []byte, value interface{}) error
- func (gc *GoCache) SetWithExpiration(key []byte, value interface{}, expiration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Add(key []byte, value interface{}) error AddWithExpiration(key []byte, value interface{}, expiration time.Duration) error Get(key []byte) (value interface{}, found bool) Set(key []byte, value interface{}) error SetWithExpiration(key []byte, value interface{}, expiration time.Duration) error }
Cache is an anstract cache layer
type GoCache ¶
type GoCache struct {
// contains filtered or unexported fields
}
GoCache is the caching layer implemented by go-cache.
func NewGoCache ¶
NewGoCache creates a go-cache cache with a given default expiration duration and cleanup interval.
func (*GoCache) Add ¶
Add adds an item to the cache only if an item doesn't already exist for the given key, or if the existing item has expired, using the default expiration. Returns an error otherwise.
func (*GoCache) AddWithExpiration ¶
AddWithExpiration adds an item to the cache only if an item doesn't already exist for the given key, or if the existing item has expired, using specified expiration. Returns an error otherwise.
func (*GoCache) Get ¶
Get gets an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.