Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DedupStringArray ¶
func SortForAutocomplete ¶
Types ¶
type ConcurrentCounter ¶
type ConcurrentCounter struct {
// contains filtered or unexported fields
}
A thread-safe counter data structure
func NewConcurrentCounter ¶
func NewConcurrentCounter(shardingMap *ShardingMap[int]) *ConcurrentCounter
func NewDefaultConcurrentCounter ¶
func NewDefaultConcurrentCounter(shardingProvider MapShardingProvider) *ConcurrentCounter
func (*ConcurrentCounter) Get ¶
func (c *ConcurrentCounter) Get(key string) int
func (*ConcurrentCounter) Incr ¶
func (c *ConcurrentCounter) Incr(key string) int
type MapShardingProvider ¶
type MapShardingProvider interface { // GetMaxShardCount returns the maximum count of shards. This must be constant value. GetMaxShardCount() int // GetShard returns the index of shard mapping to the given key. The index must be less than the returned value of GetMaxShardCount() GetShard(key string) int }
MapShardingProvider interface defines how keys are mapped to specific shard.
type ShardingMap ¶
type ShardingMap[T any] struct { // contains filtered or unexported fields }
ShardingMap provides locks by shards in a large map. This prevents lock entire map to access single element in a map.
func NewShardingMap ¶
func NewShardingMap[T any](shardingProvider MapShardingProvider) *ShardingMap[T]
func (*ShardingMap[T]) AcquireShard ¶
func (m *ShardingMap[T]) AcquireShard(key string) map[string]T
func (*ShardingMap[T]) AcquireShardReadonly ¶
func (m *ShardingMap[T]) AcquireShardReadonly(key string) map[string]T
func (*ShardingMap[T]) AllKeys ¶
func (m *ShardingMap[T]) AllKeys() (result []string)
func (*ShardingMap[T]) ReleaseShard ¶
func (m *ShardingMap[T]) ReleaseShard(key string)
func (*ShardingMap[T]) ReleaseShardReadonly ¶
func (m *ShardingMap[T]) ReleaseShardReadonly(key string)
type SuffixShardingProvider ¶
type SuffixShardingProvider struct { ShardCount int // contains filtered or unexported fields }
func NewSuffixShardingProvider ¶
func NewSuffixShardingProvider(shardCount int, suffixLength int) *SuffixShardingProvider
func (*SuffixShardingProvider) GetMaxShardCount ¶
func (h *SuffixShardingProvider) GetMaxShardCount() int
GetMaxShardCount implements MapShardingProvider.
func (*SuffixShardingProvider) GetShard ¶
func (h *SuffixShardingProvider) GetShard(key string) int
GetShard implements MapShardingProvider.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.