Documentation ¶
Index ¶
- Constants
- func SimpleSharding(key uint32) uint32
- type AdaptiveRadixTree
- func (t *AdaptiveRadixTree) Delete(key []byte) (val interface{}, updated bool)
- func (t *AdaptiveRadixTree) Get(key []byte) interface{}
- func (t *AdaptiveRadixTree) Iterator() art.Iterator
- func (t *AdaptiveRadixTree) PrefixScan(prefix []byte, count int) (keys [][]byte)
- func (t *AdaptiveRadixTree) Put(key []byte, value interface{}) (oldVal interface{}, updated bool)
- func (t *AdaptiveRadixTree) Size() int
- type ConcurrentMap
- func (cm *ConcurrentMap[K]) Get(key K) (any, bool)
- func (cm *ConcurrentMap[K]) GetShard(key K) *MapShard[K]
- func (cm *ConcurrentMap[K]) GetShardByReading(key K) *MapShard[K]
- func (cm *ConcurrentMap[K]) GetShardByWriting(key K) *MapShard[K]
- func (cm *ConcurrentMap[K]) Has(key K) bool
- func (cm *ConcurrentMap[K]) Pop(key K) (any, bool)
- func (cm *ConcurrentMap[K]) Remove(key K)
- func (cm *ConcurrentMap[K]) Set(key K, value any)
- func (cm *ConcurrentMap[K]) Size() int
- type MapShard
Constants ¶
const (
DefaultShardCount = 32
)
Variables ¶
This section is empty.
Functions ¶
func SimpleSharding ¶
Types ¶
type AdaptiveRadixTree ¶
type AdaptiveRadixTree struct {
// contains filtered or unexported fields
}
func NewART ¶
func NewART() *AdaptiveRadixTree
func (*AdaptiveRadixTree) Delete ¶
func (t *AdaptiveRadixTree) Delete(key []byte) (val interface{}, updated bool)
func (*AdaptiveRadixTree) Get ¶
func (t *AdaptiveRadixTree) Get(key []byte) interface{}
func (*AdaptiveRadixTree) Iterator ¶
func (t *AdaptiveRadixTree) Iterator() art.Iterator
func (*AdaptiveRadixTree) PrefixScan ¶
func (t *AdaptiveRadixTree) PrefixScan(prefix []byte, count int) (keys [][]byte)
PrefixScan returns keys start with specific prefix Count refers to the maximum number of retrieved keys. No limitation if count is smaller than 0.
func (*AdaptiveRadixTree) Put ¶
func (t *AdaptiveRadixTree) Put(key []byte, value interface{}) (oldVal interface{}, updated bool)
func (*AdaptiveRadixTree) Size ¶
func (t *AdaptiveRadixTree) Size() int
type ConcurrentMap ¶
type ConcurrentMap[K comparable] struct { // contains filtered or unexported fields }
func NewConcurrentMap ¶
func NewConcurrentMap(mapShardCount int) *ConcurrentMap[string]
NewConcurrentMap returns a ConcurrentMap[string] with string keys by default.
func NewWithCustomShardingFunction ¶
func NewWithCustomShardingFunction[K comparable](mapShardCount int, sharding func(key K) uint32) *ConcurrentMap[K]
NewWithCustomShardingFunction creates a new concurrent map.
func (*ConcurrentMap[K]) Get ¶
func (cm *ConcurrentMap[K]) Get(key K) (any, bool)
Get gets the value under a given key.
func (*ConcurrentMap[K]) GetShard ¶
func (cm *ConcurrentMap[K]) GetShard(key K) *MapShard[K]
GetShard returns the MapShard under the given key.
func (*ConcurrentMap[K]) GetShardByReading ¶
func (cm *ConcurrentMap[K]) GetShardByReading(key K) *MapShard[K]
GetShardByReading returns the MapShard under the given key after RLocking. Remember to unlock the shard!
func (*ConcurrentMap[K]) GetShardByWriting ¶
func (cm *ConcurrentMap[K]) GetShardByWriting(key K) *MapShard[K]
GetShardByWriting returns the MapShard under the given key after Locking. Remember to unlock the shard!
func (*ConcurrentMap[K]) Has ¶
func (cm *ConcurrentMap[K]) Has(key K) bool
Has returns if the map contains a specific key.
func (*ConcurrentMap[K]) Pop ¶
func (cm *ConcurrentMap[K]) Pop(key K) (any, bool)
Pop deletes an element from the map and returns it.
func (*ConcurrentMap[K]) Remove ¶
func (cm *ConcurrentMap[K]) Remove(key K)
Remove deletes an element from the map.
func (*ConcurrentMap[K]) Set ¶
func (cm *ConcurrentMap[K]) Set(key K, value any)
Set sets the key and value under a specific MapShard.
func (*ConcurrentMap[K]) Size ¶
func (cm *ConcurrentMap[K]) Size() int
Size returns the number of keys
type MapShard ¶
type MapShard[K comparable] struct { sync.RWMutex // r&w lock for every shard // contains filtered or unexported fields }