syncmap

package
v0.0.0-...-c0fde58 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RwSyncMap

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

RwSyncMap is a SyncMap implementation

func (*RwSyncMap) Get

func (m *RwSyncMap) Get(key string) (interface{}, bool)

func (*RwSyncMap) GetOrSet

func (m *RwSyncMap) GetOrSet(key string, creator func(key string) (interface{}, error)) (interface{}, error)

func (*RwSyncMap) Remove

func (m *RwSyncMap) Remove(key string)

func (*RwSyncMap) Set

func (m *RwSyncMap) Set(key string, val interface{})

type SyncMap

type SyncMap interface {
	// Get item from SyncMap
	Get(key string) (interface{}, bool)
	// Set item to SyncMap
	Set(key string, val interface{})
	// GetOrSet get item first, if not found, it will use creator to create one and return
	GetOrSet(key string, creator func(key string) (interface{}, error)) (interface{}, error)
	// Remove item from SyncMap
	Remove(key string)
}

SyncMap is similar as sync.Map and add GetOrSet by creator

func NewSyncMap

func NewSyncMap() SyncMap

NewSyncMap constructor for SyncMap

Jump to

Keyboard shortcuts

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