Documentation ¶
Index ¶
- func Sec(sec int) time.Time
- type Cache
- func (c *Cache) Add(key, val interface{}, expireAt ...time.Time)
- func (c *Cache) Get(key interface{}) interface{}
- func (c *Cache) Has(key interface{}) bool
- func (c *Cache) Keys() []interface{}
- func (c *Cache) Len() int
- func (c *Cache) Peek(key interface{}) interface{}
- func (c *Cache) Remove(key interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe LRU cache.
func NewCacheWithExpiringEntry ¶
NewCacheWithExpiringEntry creates a new Cache instance that removes expired entries periodically and during insertions. This cache is useful for when an item needs to be removed even before it is evicted by the LRU logic. cleanupInt sets the interval between clean up operations.
func (*Cache) Add ¶
Register adds an item. It the cache becomes full, the oldest item is evicted to make room for the new item. If this cache supports removal of explicit expiring entries, they are first removed before addition of a new entry.
func (*Cache) Get ¶
func (c *Cache) Get(key interface{}) interface{}
Get gets an item and updates the newness of the item
func (*Cache) Has ¶
Has checks whether an item is in the cache without updating the newness of the item