Documentation ¶
Index ¶
- type Map
- func (m *Map) Clear()
- func (m *Map) ComputeIfAbsent(key interface{}, computeFunc func(key interface{}) interface{}) (actual interface{}, loaded bool)
- func (m *Map) ComputeIfPresent(key interface{}, computeFunc func(key, value interface{}) interface{}) (actual interface{}, exist bool)
- func (m *Map) Delete(key interface{})
- func (m *Map) Load(key interface{}) (value interface{}, ok bool)
- func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)
- func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (m *Map) Range(f func(key, value interface{}) bool)
- func (m *Map) Store(key, value interface{})
- type ResourceManager
- type SharedBlockMap
- type SharedMap
- func (m SharedMap) Clear()
- func (m *SharedMap) ComputeIfAbsent(key string, computeFunc func(key string) interface{}) (actual interface{}, loaded bool)
- func (m *SharedMap) ComputeIfPresent(key string, computeFunc func(key string, value interface{}) interface{}) (actual interface{}, exist bool)
- func (m SharedMap) Delete(key string)
- func (m SharedMap) GetShard(key string) *SharedBlockMap
- func (m *SharedMap) Has(key string) bool
- func (m *SharedMap) Load(key string) (interface{}, bool)
- func (m *SharedMap) LoadOrStore(key string, value interface{}) bool
- func (m SharedMap) MStore(data map[string]interface{})
- func (m *SharedMap) Range(fn func(key, value interface{}) bool)
- func (m SharedMap) Store(key string, value interface{})
- type SharedMapOption
- type Spinlock
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 from standard library
func (*Map) ComputeIfAbsent ¶
func (m *Map) ComputeIfAbsent(key interface{}, computeFunc func(key interface{}) interface{}) (actual interface{}, loaded bool)
ComputeIfAbsent if the value corresponding to the key does not exist, use the recalculated value obtained by remappingFunction and save it as the value of the key, otherwise return the value.
func (*Map) ComputeIfPresent ¶
func (m *Map) ComputeIfPresent(key interface{}, computeFunc func(key, value interface{}) interface{}) (actual interface{}, exist bool)
ComputeIfPresent if the value corresponding to the key does not exist, the null is returned, and if it exists, the value recalculated by remappingFunction is returned.
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) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
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) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.
Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager is a resource manager.
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
NewResourceManager returns a ResourceManager.
func (*ResourceManager) Close ¶
func (m *ResourceManager) Close() error
Close the manager. Don't use the ResourceManager after Close() called.
func (*ResourceManager) Remove ¶
func (m *ResourceManager) Remove(key string) (exist bool)
Remove the resource associated with given key and return it if existed.
type SharedBlockMap ¶ added in v0.1.12
type SharedBlockMap = Map
SharedBlockMap is an alias that describes the block map.
type SharedMap ¶ added in v0.1.12
type SharedMap struct {
// contains filtered or unexported fields
}
SharedMap represents a segment lock map.
func NewSharedMap ¶ added in v0.1.15
func NewSharedMap(opts ...SharedMapOption) *SharedMap
NewSharedMap returns a SharedMap.
func (SharedMap) Clear ¶ added in v0.1.12
func (m SharedMap) Clear()
Clear removes all items from map.
func (*SharedMap) ComputeIfAbsent ¶ added in v0.1.12
func (m *SharedMap) ComputeIfAbsent(key string, computeFunc func(key string) interface{}) (actual interface{}, loaded bool)
ComputeIfAbsent if the value corresponding to the key does not exist, use the recalculated value obtained by remappingFunction and save it as the value of the key, otherwise return the value.
func (*SharedMap) ComputeIfPresent ¶ added in v0.1.12
func (m *SharedMap) ComputeIfPresent(key string, computeFunc func(key string, value interface{}) interface{}) (actual interface{}, exist bool)
ComputeIfPresent if the value corresponding to the key does not exist, the null is returned, and if it exists, the value recalculated by remappingFunction is returned.
func (SharedMap) GetShard ¶ added in v0.1.12
func (m SharedMap) GetShard(key string) *SharedBlockMap
GetShard returns shard under given key.
func (*SharedMap) Load ¶ added in v0.1.12
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 (*SharedMap) LoadOrStore ¶ added in v0.1.12
LoadOrStore the given value under the specified key if no value was associated with it.
type SharedMapOption ¶ added in v0.1.12
type SharedMapOption func(*sharedMapOptions)
SharedMapOption configuration function of SharedMap.
func WithShardBlockSize ¶ added in v0.1.12
func WithShardBlockSize(shardBlockSize int) SharedMapOption
WithShardBlockSize returns a configuration that sets the size of the number of segments.