dict

package
v0.0.0-...-c3f54fb Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentDict

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

并发安全的字典

func NewConcurrentDict

func NewConcurrentDict(shardCount int) *ConcurrentDict

构造字典对象

func (*ConcurrentDict) AddVersion

func (c *ConcurrentDict) AddVersion(key string, delta int64) (val interface{}, exist bool)

AddVersion 对key增加版本号

func (*ConcurrentDict) Count

func (c *ConcurrentDict) Count() int

元素个数

func (*ConcurrentDict) Delete

func (c *ConcurrentDict) Delete(key string) (interface{}, int)

删除key

func (*ConcurrentDict) DeleteWithLock

func (c *ConcurrentDict) DeleteWithLock(key string) (val interface{}, result int)

func (*ConcurrentDict) ForEach

func (c *ConcurrentDict) ForEach(consumer Consumer)

遍历

func (*ConcurrentDict) Get

func (c *ConcurrentDict) Get(key string) (val interface{}, exist bool)

获取key保存的值

func (*ConcurrentDict) GetWithLock

func (c *ConcurrentDict) GetWithLock(key string) (val interface{}, exists bool)

func (*ConcurrentDict) Put

func (c *ConcurrentDict) Put(key string, val interface{}) int

保存key(insert or update)

func (*ConcurrentDict) PutIfAbsent

func (c *ConcurrentDict) PutIfAbsent(key string, val interface{}) int

保存key( only insert)

func (*ConcurrentDict) PutIfAbsentWithLock

func (c *ConcurrentDict) PutIfAbsentWithLock(key string, val interface{}) int

保存key( only insert)

func (*ConcurrentDict) PutIfExist

func (c *ConcurrentDict) PutIfExist(key string, val interface{}) int

保存key (only update)

func (*ConcurrentDict) PutIfExistWithLock

func (c *ConcurrentDict) PutIfExistWithLock(key string, val interface{}) int

保存key (only update)

func (*ConcurrentDict) PutWithLock

func (c *ConcurrentDict) PutWithLock(key string, val interface{}) int

保存key(insert or update)

func (*ConcurrentDict) RWLock

func (c *ConcurrentDict) RWLock(readKeys, writeKeys []string)

加【读写锁】

func (*ConcurrentDict) RWUnLock

func (c *ConcurrentDict) RWUnLock(readKeys, writeKeys []string)

解【读写锁】

type Consumer

type Consumer func(key string, val interface{}) bool

Jump to

Keyboard shortcuts

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