udzura / cmap

thread-safe concurrent map for go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmap

MIT License GoDoc Go Report Card Releases

cmap is inspired by orcaman/concurrent-map, with performance improvements and some usable methods, while keeping same use cases.

Installation

$ go get github.com/octu0/cmap

Example

import "github.com/octu0/cmap

var (
  m = cmap.New()
)

func main() {
  m.Set("foo", "bar")

  if v, ok := m.Get("foo"); ok {
    bar := v.(string)
  }

  m.Remove("foo")
}

Benchmarks

goos: darwin
goarch: amd64
pkg: github.com/octu0/cmap
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkCompare/ConcurrentMap-8         	     496	   2806827 ns/op	  735840 B/op	    5153 allocs/op
BenchmarkCompare/sync.Map-8              	     252	   4720666 ns/op	  852128 B/op	   25158 allocs/op
BenchmarkCompare/cmap-8                  	     799	   1506810 ns/op	  468819 B/op	    5011 allocs/op
PASS

License

MIT, see LICENSE file for details.

About

thread-safe concurrent map for go

License:MIT License


Languages

Language:Go 100.0%