test

package
v0.0.0-...-404c222 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const SHARE_COUNT int = 64

SHARE_COUNT 默认分片数

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentMap

type ConcurrentMap []*ConcurrentMapShared

ConcurrentMap 总的map

func NewConcurrentMap

func NewConcurrentMap() *ConcurrentMap

NewConcurrentMap 新建一个map

func (ConcurrentMap) Count

func (m ConcurrentMap) Count() int

Count 统计key个数

func (ConcurrentMap) Get

func (m ConcurrentMap) Get(key string) (value interface{}, ok bool)

Get 获取key对应的value

func (ConcurrentMap) GetSharedMap

func (m ConcurrentMap) GetSharedMap(key string) *ConcurrentMapShared

GetSharedMap 获取key对应的map分片

func (ConcurrentMap) Keys1

func (m ConcurrentMap) Keys1() []string

Keys1 所有的key方法1(方法:遍历每个分片map,读取key;缺点:量大时,阻塞时间较长)

func (ConcurrentMap) Keys2

func (m ConcurrentMap) Keys2() []string

Keys2 所有的key方法2(方法:开多个协程分别对分片map做统计再汇总 优点:量大时,阻塞时间较短)

func (ConcurrentMap) Set

func (m ConcurrentMap) Set(key string, value interface{})

Set 设置key,value

type ConcurrentMapShared

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

ConcurrentMapShared 单个map分片

type MutexMap

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

MutexMap 对外暴露的map

func NewMutexMap

func NewMutexMap() *MutexMap

NewMutexMap 新建一个map

func (MutexMap) Count

func (m MutexMap) Count() int

Count 统计key个数

func (MutexMap) Get

func (m MutexMap) Get(key string) (value interface{}, ok bool)

Get 获取key对应的value

func (MutexMap) Keys

func (m MutexMap) Keys() []string

Keys 所有的key

func (MutexMap) Set

func (m MutexMap) Set(key string, value interface{})

Set 设置key,value

Jump to

Keyboard shortcuts

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