Documentation ¶
Index ¶
- type Map
- func (m *Map) Delete(key interface{})
- func (m *Map) DeleteWithFunc(key interface{}, onDeleteFunc func(value interface{}))
- func (m *Map) Length() int
- func (m *Map) Load(key interface{}) (value interface{}, ok bool)
- func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (m *Map) LoadOrStoreWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}, ...) (actual interface{}, loaded bool)
- func (m *Map) LoadWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}) (value interface{}, ok bool)
- func (m *Map) PullOut(key interface{}) (value interface{}, ok bool)
- func (m *Map) PullOutAll() (data map[interface{}]interface{})
- func (m *Map) PullOutWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}) (value interface{}, ok bool)
- func (m *Map) Range(f func(key, value interface{}) bool)
- func (m *Map) Replace(key, value interface{}) (oldValue interface{}, oldLoaded bool)
- func (m *Map) ReplaceWithFunc(key interface{}, ...) (oldValue interface{}, oldLoaded bool)
- func (m *Map) Store(key, value interface{})
- func (m *Map) StoreWithFunc(key interface{}, createFunc func() interface{})
- type Once
- type Pool
- type PoolFunc
- type RefCounter
- type ReleaseDataFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines.
func (*Map) DeleteWithFunc ¶
func (m *Map) DeleteWithFunc(key interface{}, onDeleteFunc func(value interface{}))
func (*Map) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*Map) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*Map) LoadOrStoreWithFunc ¶
func (*Map) LoadWithFunc ¶
func (*Map) PullOutAll ¶
func (m *Map) PullOutAll() (data map[interface{}]interface{})
PullOutAll extracts internal map data and replace it with empty map.
func (*Map) PullOutWithFunc ¶
func (*Map) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
func (*Map) Replace ¶
Replace replaces the existing value with a new value and returns old value for the key.
func (*Map) ReplaceWithFunc ¶
func (*Map) StoreWithFunc ¶
func (m *Map) StoreWithFunc(key interface{}, createFunc func() interface{})
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
Once performs exactly one action. See sync.Once for more details.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a synchronized key-value store with customizable factory for missing items.
func (*Pool) GetOrCreate ¶
GetOrCreate returns an item and calls the factory on a mis. Warning: The factory function is called under the lock, therefore it must not call any Pool's methods to avoid deadlocks.
func (*Pool) SetFactory ¶
SetFactory sets the pool factory for GetOrCreate.
type PoolFunc ¶
PoolFunc is triggered on a miss by GetOrCreate, so that it may add the missing item to the pool.
type RefCounter ¶
type RefCounter struct {
// contains filtered or unexported fields
}
func NewRefCounter ¶
func NewRefCounter(data interface{}, releaseDataFunc ReleaseDataFunc) *RefCounter
NewRefCounter creates RefCounter