Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache is a thread-safe size-bounded LRU cache.
type SimpleCache ¶
type SimpleCache[K comparable, V any] struct { // contains filtered or unexported fields }
SimpleCache is a non-thread-safe size-bounded LRU cache. Use when external synchronization is provided (e.g. single-goroutine ownership).
func NewSimple ¶
func NewSimple[K comparable, V any](size int) *SimpleCache[K, V]
NewSimple returns a new non-thread-safe LRU cache or panics if size <= 0.
func (*SimpleCache[K, V]) Add ¶
func (l *SimpleCache[K, V]) Add(key K, value V) (evicted bool)
func (*SimpleCache[K, V]) Get ¶
func (l *SimpleCache[K, V]) Get(key K) (V, bool)
func (*SimpleCache[K, V]) Len ¶
func (l *SimpleCache[K, V]) Len() int
func (*SimpleCache[K, V]) Purge ¶
func (l *SimpleCache[K, V]) Purge()
func (*SimpleCache[K, V]) Remove ¶
func (l *SimpleCache[K, V]) Remove(key K) (present bool)
Click to show internal directories.
Click to hide internal directories.