Documentation
¶
Index ¶
- Variables
- func EnableExpired(ttl time.Duration) func(option *Option)
- type ConcurrentMap
- func (m *ConcurrentMap[T]) Delete(key string)
- func (m *ConcurrentMap[T]) Get(key string) (value T, ok bool)
- func (m *ConcurrentMap[T]) GetShard(key string) uint32
- func (m *ConcurrentMap[T]) Set(key string, value T, ttl ...time.Duration)
- func (m *ConcurrentMap[T]) SetByFunc(key string, newValueFunc func(oldValue T) (newValue T), ttl ...time.Duration) (newValue T)
- type ExpirationHeap
- type Node
- type Option
- type RWMutexMap
- func (s *RWMutexMap[T]) Clear()
- func (s *RWMutexMap[T]) Delete(key string)
- func (s *RWMutexMap[T]) Get(key string) (val T, ok bool)
- func (s *RWMutexMap[T]) Set(key string, value T, ttl ...time.Duration)
- func (s *RWMutexMap[T]) SetByFunc(key string, newValueFunc func(oldValue T) (newValue T), ttl ...time.Duration) (newValue T)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SHARD_COUNT uint32 = 32 // 只能在NewConcurrentMap之前修改 AUTO_CLEAR_INTERVAL = 10 * time.Minute // 可修改 )
Functions ¶
Types ¶
type ConcurrentMap ¶
type ConcurrentMap[T any] struct { // contains filtered or unexported fields }
分成SHARD_COUNT个分片的map
func NewConcurrentMap ¶
func NewConcurrentMap[T any](options ...func(option *Option)) *ConcurrentMap[T]
创建并发map
func (*ConcurrentMap[T]) Delete ¶
func (m *ConcurrentMap[T]) Delete(key string)
func (*ConcurrentMap[T]) Get ¶
func (m *ConcurrentMap[T]) Get(key string) (value T, ok bool)
func (*ConcurrentMap[T]) GetShard ¶
func (m *ConcurrentMap[T]) GetShard(key string) uint32
根据key计算分片索引
type ExpirationHeap ¶ added in v0.1.10
func (ExpirationHeap[T]) Len ¶ added in v0.1.10
func (e ExpirationHeap[T]) Len() int
func (ExpirationHeap[T]) Less ¶ added in v0.1.10
func (e ExpirationHeap[T]) Less(i, j int) bool
func (*ExpirationHeap[T]) Pop ¶ added in v0.1.10
func (e *ExpirationHeap[T]) Pop() any
func (*ExpirationHeap[T]) Push ¶ added in v0.1.10
func (e *ExpirationHeap[T]) Push(x any)
func (ExpirationHeap[T]) Swap ¶ added in v0.1.10
func (e ExpirationHeap[T]) Swap(i, j int)
type RWMutexMap ¶
type RWMutexMap[T any] struct { // contains filtered or unexported fields }
通过RWMutex保护的线程安全的分片,包含一个map
func NewRWMutexMap ¶ added in v0.1.10
func NewRWMutexMap[T any](ttl time.Duration) *RWMutexMap[T]
func (*RWMutexMap[T]) Delete ¶
func (s *RWMutexMap[T]) Delete(key string)
func (*RWMutexMap[T]) Get ¶
func (s *RWMutexMap[T]) Get(key string) (val T, ok bool)
Click to show internal directories.
Click to hide internal directories.