Documentation ¶
Index ¶
- type ConcurrentMap
- func (c *ConcurrentMap) Del(key string)
- func (c *ConcurrentMap) Get(key string) (v interface{}, ok bool)
- func (c *ConcurrentMap) Len() int
- func (c *ConcurrentMap) RangeDo(f func(key string, v interface{}))
- func (c *ConcurrentMap) Set(key string, v interface{})
- func (c *ConcurrentMap) TestAndSet(key string, f TestAndSetFunc) (passed bool)
- type TestAndSetFunc
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 ¶
Click to show internal directories.
Click to hide internal directories.