Documentation ¶
Overview ¶
Package lru enables caching bytes of data using an in-memory Least Recently Used cache.
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 an in-memory Least Recently Used cache that is safe to use for concurrent writes from multiple goroutines.
func New ¶
New creates and returns a LRU (Least Recently Used) cache with a maximum size specified in bytes. The cache size must be a number greater than 0, otherwise en error will be returned.
func (*Cache) Clr ¶
func (c *Cache) Clr()
Clr removes and clears every item from the cache, and resets its size.
func (*Cache) Del ¶
Del deletes a key from the cache. If the value existed in the cache then the value is returned, otherwise a nil byte slice is returned.
func (*Cache) Get ¶
Get looks up a key's value in the cache. If the value exists in the cache then the value is returned, otherwise a nil byte slice is returned.