Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[K comparable, V any] func(*ShardingMap[K, V])
Option defines the options for configuring the ShardingMap
func WithShardCount ¶
func WithShardCount[K comparable, V any](count int) Option[K, V]
WithShardCount sets the number of shards
func WithShardingFunc ¶
func WithShardingFunc[K comparable, V any](fn func(K) int) Option[K, V]
WithShardingFunc sets a custom sharding function
type Shard ¶
type Shard[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields }
Shard defines the structure of each shard
type ShardingMap ¶
type ShardingMap[K comparable, V any] struct { // contains filtered or unexported fields }
ShardingMap defines the structure of the entire sharding map
func New ¶
func New[K comparable, V any](opts ...Option[K, V]) *ShardingMap[K, V]
New creates a new ShardingMap with support for options
func (*ShardingMap[K, V]) Delete ¶
func (sm *ShardingMap[K, V]) Delete(key K)
Delete removes the key
func (*ShardingMap[K, V]) ForEach ¶
func (sm *ShardingMap[K, V]) ForEach(f func(K, V))
ForEach iterates over all key-value pairs
func (*ShardingMap[K, V]) Get ¶
func (sm *ShardingMap[K, V]) Get(key K) (V, bool)
Get retrieves the value corresponding to the key
func (*ShardingMap[K, V]) Len ¶
func (sm *ShardingMap[K, V]) Len() int
Len returns the total number of elements in the ShardingMap
func (*ShardingMap[K, V]) Set ¶
func (sm *ShardingMap[K, V]) Set(key K, value V)
Set sets the key-value pair
Click to show internal directories.
Click to hide internal directories.