modulepackage
0.0.0-20160823150647-8bf1e9bacbf6
Repository: https://github.com/streamrail/concurrent-map.git
Documentation: pkg.go.dev
# README
concurrent map 
As explained here and here, the map
type in Go doesn't support concurrent reads and writes. concurrent-map
provides a high-performance solution to this by sharding the map with minimal time spent waiting for locks.
usage
Import the package:
import (
"github.com/streamrail/concurrent-map"
)
go get "github.com/streamrail/concurrent-map"
The package is now imported under the "cmap" namespace.
example
// Create a new map.
map := cmap.New()
// Sets item within map, sets "bar" under key "foo"
map.Set("foo", "bar")
// Retrieve item from map.
if tmp, ok := map.Get("foo"); ok {
bar := tmp.(string)
}
// Removes item under key "foo"
map.Remove("foo")
For more examples have a look at concurrent_map_test.go.
Running tests:
go test "github.com/streamrail/concurrent-map"
license
MIT (see LICENSE file)
# Functions
Creates a new concurrent map.
# Variables
No description provided by the author
# Structs
A "thread" safe string to anything map.
Used by the Iter & IterBuffered functions to wrap two variables together over a channel,.
# Type aliases
A "thread" safe map of type string:Anything.
Iterator callback,called for every key,value found in maps.
Callback to return new element to be inserted into the map It is called while lock is held, therefore it MUST NOT try to access other keys in same map, as it can lead to deadlock since Go sync.RWLock is not reentrant.