Documentation ¶
Index ¶
- Variables
- type LRUCache
- func (cache *LRUCache) ComputeIfAbsent(key interface{}, callback func() interface{}) (result interface{})
- func (cache *LRUCache) ComputeIfPresent(key interface{}, callback func(value interface{}) interface{}) (result interface{})
- func (cache *LRUCache) Contains(key interface{}) (result bool)
- func (cache *LRUCache) Delete(key interface{}) bool
- func (cache *LRUCache) DeleteAll()
- func (cache *LRUCache) DeleteWithoutEviction(key interface{}) (existed bool, keyToEvict interface{}, valueToEvict interface{})
- func (cache *LRUCache) Get(key interface{}) (result interface{})
- func (cache *LRUCache) GetCapacity() int
- func (cache *LRUCache) GetSize() int
- func (cache *LRUCache) Set(key interface{}, value interface{})
- type LRUCacheOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var DEFAULT_OPTIONS = &LRUCacheOptions{ EvictionCallback: nil, EvictionBatchSize: 1, IdleTimeout: 30 * time.Second, }
Functions ¶
This section is empty.
Types ¶
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func NewLRUCache ¶
func NewLRUCache(capacity int, options ...*LRUCacheOptions) *LRUCache
func (*LRUCache) ComputeIfAbsent ¶
func (cache *LRUCache) ComputeIfAbsent(key interface{}, callback func() interface{}) (result interface{})
func (*LRUCache) ComputeIfPresent ¶
func (cache *LRUCache) ComputeIfPresent(key interface{}, callback func(value interface{}) interface{}) (result interface{})
Calls the callback if an entry with the given key exists. The result of the callback is written back into the cache. If the callback returns nil the entry is removed from the cache. Returns the updated entry.
func (*LRUCache) DeleteWithoutEviction ¶
func (*LRUCache) GetCapacity ¶
type LRUCacheOptions ¶
Click to show internal directories.
Click to hide internal directories.