Documentation
¶
Index ¶
- type Map
- type Opts
- type Shard
- func (m *Shard[K, V]) Delete(key K)
- func (m *Shard[K, V]) Get(key K) (v V, expiresAt time.Time, ok bool)
- func (m *Shard[K, V]) GetValue(key K) (v V, ok bool)
- func (m *Shard[K, V]) Lock()
- func (m *Shard[K, V]) Set(key K, value V, expiresAt time.Time)
- func (m *Shard[K, V]) SetNow(now *time.Time)
- func (m *Shard[K, V]) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] = sharder[K, Shard[K, V]]
Map is a sharded map with sharded locks with automatic, amortised cleanup based on item expiry times. Should be pretty efficient and low drama
func New ¶
func New[K comparable, V any]() *Map[K, V]
func NewWithOpts ¶
func NewWithOpts[K comparable, V any](opts Opts) *Map[K, V]
type Opts ¶
type Opts struct {
// Number of internal map shards. Must be power of 2. Defaults to 32.
Shards int
}
type Shard ¶
type Shard[K comparable, V any] struct { // contains filtered or unexported fields }
func (*Shard[K, V]) Delete ¶
func (m *Shard[K, V]) Delete(key K)
Delete must be called while Lock is held
Click to show internal directories.
Click to hide internal directories.