https://github.com/octu0/cmap
thread-safe concurrent map for go
https://github.com/octu0/cmap
concurrent-map golang goroutine goroutine-safe map thread-safe
Last synced: 3 months ago
JSON representation
thread-safe concurrent map for go
- Host: GitHub
- URL: https://github.com/octu0/cmap
- Owner: octu0
- License: mit
- Created: 2021-09-22T12:43:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T08:27:38.000Z (about 3 years ago)
- Last Synced: 2024-12-30T03:43:13.612Z (over 1 year ago)
- Topics: concurrent-map, golang, goroutine, goroutine-safe, map, thread-safe
- Language: Go
- Homepage: https://pkg.go.dev/github.com/octu0/cmap
- Size: 21.5 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmap
[](https://github.com/octu0/cmap/blob/master/LICENSE)
[](https://godoc.org/github.com/octu0/cmap)
[](https://goreportcard.com/report/github.com/octu0/cmap)
[](https://github.com/octu0/cmap/releases)
`cmap` is inspired by [orcaman/concurrent-map](https://github.com/orcaman/concurrent-map), with performance improvements and some usable methods, while keeping same use cases.
## Installation
```
$ go get github.com/octu0/cmap
```
## Example
```go
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.