concurrent_lru

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentLRU

type ConcurrentLRU[K comparable, V any] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ConcurrentLRU is a lru.LRU with a lock. It is concurrent safe.

func NewConecurrentLRU

func NewConecurrentLRU[K comparable, V any](maxSize int, onEvict func(key K, v V)) *ConcurrentLRU[K, V]

func (*ConcurrentLRU[K, V]) Add

func (c *ConcurrentLRU[K, V]) Add(key K, v V)

func (*ConcurrentLRU[K, V]) Clean

func (c *ConcurrentLRU[K, V]) Clean(f func(key K, v V) (remove bool)) (removed int)

func (*ConcurrentLRU[K, V]) Del

func (c *ConcurrentLRU[K, V]) Del(key K)

func (*ConcurrentLRU[K, V]) Flush

func (c *ConcurrentLRU[K, V]) Flush()

func (*ConcurrentLRU[K, V]) Get

func (c *ConcurrentLRU[K, V]) Get(key K) (v V, ok bool)

func (*ConcurrentLRU[K, V]) Len

func (c *ConcurrentLRU[K, V]) Len() int

type Hashable

type Hashable interface {
	comparable
	Sum() uint64
}

type ShardedLRU

type ShardedLRU[K Hashable, V any] struct {
	// contains filtered or unexported fields
}

func NewShardedLRU

func NewShardedLRU[K Hashable, V any](
	shardNum, maxSizePerShard int,
	onEvict func(key K, v V),
) *ShardedLRU[K, V]

func (*ShardedLRU[K, V]) Add

func (c *ShardedLRU[K, V]) Add(key K, v V)

func (*ShardedLRU[K, V]) Clean

func (c *ShardedLRU[K, V]) Clean(f func(key K, v V) (remove bool)) (removed int)

func (*ShardedLRU[K, V]) Del

func (c *ShardedLRU[K, V]) Del(key K)

func (*ShardedLRU[K, V]) Flush

func (c *ShardedLRU[K, V]) Flush()

func (*ShardedLRU[K, V]) Get

func (c *ShardedLRU[K, V]) Get(key K) (v V, ok bool)

func (*ShardedLRU[K, V]) Len

func (c *ShardedLRU[K, V]) Len() int

Jump to

Keyboard shortcuts

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