Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Get(key string) (interface{}, bool)
- func (c *Cache) GetAll() []interface{}
- func (c *Cache) GetLeastRecentlyUsed() (string, interface{})
- func (c *Cache) GetOrAdd(key string, value interface{}, isInternal bool) (interface{}, bool)
- func (c *Cache) Len() int
- func (c *Cache) Remove(key string) (interface{}, bool)
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 is a LRU cache where some elements are not subject to the LRU removal strategy. This cache is safe for concurrent use.
func New ¶
func New() *Cache
New returns a freshly created cache with all its internal structures initialized
func (*Cache) Get ¶
Get returns if the key is present the value associated with it from the map and true. Otherwise the value type's zero value and false is returned
func (*Cache) GetAll ¶
func (c *Cache) GetAll() []interface{}
GetAll returns all contained values. It does not affect lru list order.
func (*Cache) GetLeastRecentlyUsed ¶
GetLeastRecentlyUsed returns the least recently used key value pair. It does not update the recentness of the element
func (*Cache) GetOrAdd ¶
GetOrAdd only inserts the key value pair to Cache if there has not yet been a mapping for key. It first returns the already existing value associated with the key or otherwise the new value. The second return value is a boolean value which is true if the mapping has not yet been present.