Documentation
¶
Index ¶
- type ShardLRU
- func (lru *ShardLRU[K, V]) Clear()
- func (lru *ShardLRU[K, V]) Contains(key K) bool
- func (lru *ShardLRU[K, V]) Delete(key K) bool
- func (lru *ShardLRU[K, V]) Get(key K) (V, bool)
- func (lru *ShardLRU[K, V]) Len() int
- func (lru *ShardLRU[K, V]) Set(key K, value V)
- func (lru *ShardLRU[K, V]) Stats() (hitRate float64, shardLoad []float64)
- type ShardLRUOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShardLRU ¶
type ShardLRU[K comparable, V any] struct { // contains filtered or unexported fields }
ShardLRU 是一个分片式的 LRU 缓存
func NewShardLRU ¶
func NewShardLRU[K comparable, V any](options ...ShardLRUOption[K, V]) *ShardLRU[K, V]
NewShardLRU 创建一个新的分片式 LRU 缓存 shardCount: 分片数量,默认为16,会向上取整为2的幂 capacity: 总容量,会平均分配给所有分片
type ShardLRUOption ¶
type ShardLRUOption[K comparable, V any] func(*ShardLRU[K, V])
func WithCapacity ¶
func WithCapacity[K comparable, V any](capacity int) ShardLRUOption[K, V]
func WithLRUOnEvict ¶
func WithLRUOnEvict[K comparable, V any](onEvict func(K, V)) ShardLRUOption[K, V]
func WithShardCount ¶
func WithShardCount[K comparable, V any](shardCount int) ShardLRUOption[K, V]
Click to show internal directories.
Click to hide internal directories.