concurrent_map

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentMap

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

ConcurrentMap is a map that is safe for concurrent use. It usually has better performance than (sync.RWMutex + map) under high workload.

func NewConcurrentMap

func NewConcurrentMap(shard int) *ConcurrentMap

func (*ConcurrentMap) Del

func (c *ConcurrentMap) Del(key string)

func (*ConcurrentMap) Get

func (c *ConcurrentMap) Get(key string) (v interface{}, ok bool)

func (*ConcurrentMap) Len

func (c *ConcurrentMap) Len() int

func (*ConcurrentMap) RangeDo

func (c *ConcurrentMap) RangeDo(f func(key string, v interface{}))

func (*ConcurrentMap) Set

func (c *ConcurrentMap) Set(key string, v interface{})

func (*ConcurrentMap) TestAndSet

func (c *ConcurrentMap) TestAndSet(key string, f TestAndSetFunc) (passed bool)

TestAndSet: Concurrent safe test-and-set operation. If f returns nil, the key will be deleted.

type TestAndSetFunc

type TestAndSetFunc func(v interface{}, ok bool) (newV interface{}, wantUpdate, testPassed bool)

Jump to

Keyboard shortcuts

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