A thread-safe map for the Go programming language.
$ go get -u github.com/LyricTian/cmap
package main
import (
"fmt"
"github.com/LyricTian/cmap"
)
func main() {
m := cmap.NewShardMap()
// or
// m := cmap.NewMap()
m.Set("foo", "bar")
if v, ok := m.Get("foo"); ok {
fmt.Println("foo=", v.(string))
}
m.Remove("foo")
}
BenchmarkMapSet-8 1000000 1032 ns/op
BenchmarkParallelMapSet-8 1000000 1217 ns/op
BenchmarkShardMapSet-8 2000000 854 ns/op
BenchmarkParallelShardMapSet-8 5000000 395 ns/op
Copyright (c) 2016 Lyric