lru_cache

package
v1.0.0-beta24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2020 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

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) Contains

func (cache *LRUCache) Contains(key interface{}) (result bool)

func (*LRUCache) Delete

func (cache *LRUCache) Delete(key interface{}) bool

func (*LRUCache) DeleteAll

func (cache *LRUCache) DeleteAll()

func (*LRUCache) DeleteWithoutEviction

func (cache *LRUCache) DeleteWithoutEviction(key interface{}) (existed bool, keyToEvict interface{}, valueToEvict interface{})

func (*LRUCache) Get

func (cache *LRUCache) Get(key interface{}) (result interface{})

func (*LRUCache) GetCapacity

func (cache *LRUCache) GetCapacity() int

func (*LRUCache) GetSize

func (cache *LRUCache) GetSize() int

func (*LRUCache) Set

func (cache *LRUCache) Set(key interface{}, value interface{})

type LRUCacheOptions

type LRUCacheOptions struct {
	EvictionCallback  func(keyOrBatchedKeys interface{}, valueOrBatchedValues interface{})
	EvictionBatchSize uint64
	IdleTimeout       time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL