Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Put an object into the cache and expire after the given ttl Put(key string, value interface{}, ttl time.Duration) // Get an object from the cache. Stale objects are returned, but marked as stale Get(key string) (value interface{}, status Result) // Size returns the max items that may be stored in the cache Size() int // Remove removes the provided key from the cache. Remove(key string) // method DOES NOT take into account TTL, so the result may include stale items. Len() int }
Cache is the abstract interface for a cache that requires an TTL duration for objects
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe fixed size LRU cache.
func NewLRUCache ¶
NewLRUCache creates an LRU of the given size
func (*LRUCache) Add ¶
func (c *LRUCache) Add(key, value interface{})
Add adds a value to the cache.
func (*LRUCache) Remove ¶
func (c *LRUCache) Remove(key interface{})
Remove removes the provided key from the cache.
func (*LRUCache) RemoveOldest ¶
func (c *LRUCache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
Click to show internal directories.
Click to hide internal directories.