Documentation ¶
Index ¶
- type ConcurrentLRU
- func (c *ConcurrentLRU[K, V]) Add(key K, v V)
- func (c *ConcurrentLRU[K, V]) Clean(f func(key K, v V) (remove bool)) (removed int)
- func (c *ConcurrentLRU[K, V]) Del(key K)
- func (c *ConcurrentLRU[K, V]) Flush()
- func (c *ConcurrentLRU[K, V]) Get(key K) (v V, ok bool)
- func (c *ConcurrentLRU[K, V]) Len() int
- type Hashable
- type ShardedLRU
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 ¶
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
Click to show internal directories.
Click to hide internal directories.