shardedmap

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StrMap

type StrMap struct {
	// contains filtered or unexported fields
}

func NewStrMap

func NewStrMap(shardCount int) *StrMap

NewStrMap ...

func (*StrMap) AsyncRange

func (sm *StrMap) AsyncRange(f func(key string, value interface{}) bool)

AsyncRange is exactly like ConcRange, but doesn't wait until all shards are done. This is usually ok, although calls that appear to happen "sequentially" on the same goroutine might get the before or after AsyncRange values, which might be surprising behaviour. When that's not desirable, use ConcRange.

func (*StrMap) ConcRange

func (sm *StrMap) ConcRange(f func(key string, value interface{}) bool)

ConcRange ranges concurrently over all the shards, calling f sequentially over each shard's key and value. If f returns false, range stops the iteration on that shard (but the other shards continue until completion).

No key will be visited more than once, but if any value is inserted concurrently, Range may or may not visit it. Similarly, if a value is modified concurrently, Range may visit the previous or newest version of said value.

func (*StrMap) Delete

func (sm *StrMap) Delete(key string)

Delete ...

func (*StrMap) Get

func (sm *StrMap) Get(key string) (interface{}, bool)

Get ...

func (*StrMap) GetOrSet

func (sm *StrMap) GetOrSet(key string, value interface{}) (actual interface{}, loaded bool)

GetOrSet ...

func (*StrMap) Len

func (sm *StrMap) Len() int

Len returns the number of values in map.

func (*StrMap) Range

func (sm *StrMap) Range(f func(key string, value interface{}) bool)

Range is modeled after sync.Map.Range. It calls f sequentially for each key and value present in each of the shards in the map. If f returns false, range stops the iteration.

No key will be visited more than once, but if any value is inserted concurrently, Range may or may not visit it. Similarly, if a value is modified concurrently, Range may visit the previous or newest version of said value.

func (*StrMap) Set

func (sm *StrMap) Set(key string, value interface{})

Set ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL