Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidMaxSize is returned when the given max size is not positive. ErrInvalidMaxSize = errors.New("max size must be > 0") )
Functions ¶
This section is empty.
Types ¶
type LRUExpireCache ¶
type LRUExpireCache struct {
// contains filtered or unexported fields
}
LRUExpireCache is a cache that ensures the mostly recently accessed keys are returned with a ttl beyond which keys are forcibly expired.
func NewLRUExpireCache ¶
func NewLRUExpireCache(maxSize int) (*LRUExpireCache, error)
NewLRUExpireCache creates an expiring cache with the given size
func (*LRUExpireCache) Add ¶
func (c *LRUExpireCache) Add( key string, value interface{}, ttl time.Duration, )
Add adds the value to the cache at key with the specified maximum duration.
func (*LRUExpireCache) Get ¶
func (c *LRUExpireCache) Get(key string) (interface{}, bool)
Get returns the value at the specified key from the cache if it exists and is not expired, or returns false.
Click to show internal directories.
Click to hide internal directories.