cmap alternatives and similar packages
Based on the "Data Structures" category.
Alternatively, view cmap alternatives based on common mentions on social networks and blogs.
-
golang-set
A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp. -
hyperloglog
HyperLogLog with lots of sugar (Sparse, LogLog-Beta bias correction and TailCut space reduction) brought to you by Axiom -
ttlcache
DISCONTINUED. An in-memory cache with item expiration and generics [Moved to: https://github.com/jellydator/ttlcache] -
Bloomfilter
DISCONTINUED. Face-meltingly fast, thread-safe, marshalable, unionable, probability- and optimal-size-calculating Bloom filter in go -
hilbert
DISCONTINUED. Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves. -
cuckoo-filter
Cuckoo Filter go implement, better than Bloom Filter, configurable and space optimized 布谷鸟过滤器的Go实现,优于布隆过滤器,可以定制化过滤器参数,并进行了空间优化 -
go-rquad
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go -
nan
Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers -
hide
A Go type to prevent internal numeric IDs from being exposed to clients using HashIDs and JSON.
SaaSHub - Software Alternatives and Reviews
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