cmap alternatives and similar packages
Based on the "Data Structures" category.
Alternatively, view cmap alternatives based on common mentions on social networks and blogs.
-
gocache
A complete Go cache library with mutiple stores (memory, memcache, redis, ...), chainable, loadable, metrics cache and more. -
hyperloglog
HyperLogLog implementation with Sparse, LogLog-Beta bias correction and TailCut space reduction. -
Bloomfilter
Face-meltingly fast, thread-safe, marshalable, unionable, probability- and optimal-size-calculating Bloom filter in go -
merkletree
Implementation of a merkle tree providing an efficient and secure verification of the contents of data structures. -
hilbert
Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves. -
gostl
Data structure and algorithm library for go, designed to provide functions similar to C++ STL. -
remember-go
A universal interface for caching slow database queries (backed by redis, memcached, ristretto, or in-memory). -
count-min-log
A Go implementation Count-Min-Log sketch: Approximately counting with approximate counters (Like Count-Min sketch but using less memory). -
nan
Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers.
Get performance insights in less than 4 minutes
Do you think we are missing an alternative of cmap or a related project?
README
cmap

The map
type in Go doesn't support concurrent reads and writes. cmap(concurrent-map)
provides a high-performance solution to this by sharding the map with minimal time spent waiting for locks.
The sync.Map
has a few key differences from this map. The stdlib sync.Map
is designed for append-only scenarios. So if you want to use the map for something more like in-memory db, you might benefit from using our version. You can read more about it in the golang repo, for example here and here
Here we fork some README document from concurrent-map
usage
Import the package:
import (
"github.com/lrita/cmap"
)
go get "github.com/lrita/cmap"
The package is now imported under the "cmap" namespace.
example
// Create a new map.
var m cmap.Cmap
// Stores item within map, sets "bar" under key "foo"
m.Store("foo", "bar")
// Retrieve item from map.
if tmp, ok := m.Load("foo"); ok {
bar := tmp.(string)
}
// Deletes item under key "foo"
m.Delete("foo")
benchmark
goos: darwin
goarch: amd64
pkg: github.com/lrita/cmap
BenchmarkLoadMostlyHits/*cmap_test.DeepCopyMap-4 50000000 34.5 ns/op
BenchmarkLoadMostlyHits/*cmap_test.RWMutexMap-4 20000000 65.2 ns/op
BenchmarkLoadMostlyHits/*sync.Map-4 50000000 34.8 ns/op
BenchmarkLoadMostlyHits/*cmap.Cmap-4 30000000 53.5 ns/op
BenchmarkLoadMostlyMisses/*cmap_test.DeepCopyMap-4 50000000 26.7 ns/op
BenchmarkLoadMostlyMisses/*cmap_test.RWMutexMap-4 20000000 62.5 ns/op
BenchmarkLoadMostlyMisses/*sync.Map-4 50000000 22.7 ns/op
BenchmarkLoadMostlyMisses/*cmap.Cmap-4 30000000 40.3 ns/op
--- SKIP: BenchmarkLoadOrStoreBalanced/*cmap_test.DeepCopyMap
cmap_bench_test.go:91: DeepCopyMap has quadratic running time.
BenchmarkLoadOrStoreBalanced/*cmap_test.RWMutexMap-4 3000000 437 ns/op
BenchmarkLoadOrStoreBalanced/*sync.Map-4 3000000 546 ns/op
BenchmarkLoadOrStoreBalanced/*cmap.Cmap-4 3000000 497 ns/op
--- SKIP: BenchmarkLoadOrStoreUnique/*cmap_test.DeepCopyMap
cmap_bench_test.go:123: DeepCopyMap has quadratic running time.
BenchmarkLoadOrStoreUnique/*cmap_test.RWMutexMap-4 2000000 990 ns/op
BenchmarkLoadOrStoreUnique/*sync.Map-4 1000000 1032 ns/op
BenchmarkLoadOrStoreUnique/*cmap.Cmap-4 2000000 892 ns/op
BenchmarkLoadOrStoreCollision/*cmap_test.DeepCopyMap-4 100000000 18.2 ns/op
BenchmarkLoadOrStoreCollision/*cmap_test.RWMutexMap-4 10000000 165 ns/op
BenchmarkLoadOrStoreCollision/*sync.Map-4 100000000 19.6 ns/op
BenchmarkLoadOrStoreCollision/*cmap.Cmap-4 20000000 65.7 ns/op
BenchmarkRange/*cmap_test.DeepCopyMap-4 200000 8646 ns/op
BenchmarkRange/*cmap_test.RWMutexMap-4 20000 62046 ns/op
BenchmarkRange/*sync.Map-4 200000 9317 ns/op
BenchmarkRange/*cmap.Cmap-4 50000 31107 ns/op
BenchmarkAdversarialAlloc/*cmap_test.DeepCopyMap-4 2000000 531 ns/op
BenchmarkAdversarialAlloc/*cmap_test.RWMutexMap-4 20000000 74.3 ns/op
BenchmarkAdversarialAlloc/*sync.Map-4 5000000 390 ns/op
BenchmarkAdversarialAlloc/*cmap.Cmap-4 30000000 53.6 ns/op
BenchmarkAdversarialDelete/*cmap_test.DeepCopyMap-4 5000000 273 ns/op
BenchmarkAdversarialDelete/*cmap_test.RWMutexMap-4 20000000 94.4 ns/op
BenchmarkAdversarialDelete/*sync.Map-4 10000000 137 ns/op
BenchmarkAdversarialDelete/*cmap.Cmap-4 30000000 43.3 ns/op