go>> cmap>> 返回
项目作者: LyricTian

项目描述 :
A thread-safe map for the Go programming language.
高级语言: Go
项目地址: git://github.com/LyricTian/cmap.git
创建时间: 2018-11-07T07:17:03Z
项目社区:https://github.com/LyricTian/cmap

开源协议:MIT License

下载


Concurrent Map

A thread-safe map for the Go programming language.

License ReportCard GoDoc

Install

  1. $ go get -u github.com/LyricTian/cmap

Usage

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/LyricTian/cmap"
  5. )
  6. func main() {
  7. m := cmap.NewShardMap()
  8. // or
  9. // m := cmap.NewMap()
  10. m.Set("foo", "bar")
  11. if v, ok := m.Get("foo"); ok {
  12. fmt.Println("foo=", v.(string))
  13. }
  14. m.Remove("foo")
  15. }

Benchmark

  1. BenchmarkMapSet-8 1000000 1032 ns/op
  2. BenchmarkParallelMapSet-8 1000000 1217 ns/op
  3. BenchmarkShardMapSet-8 2000000 854 ns/op
  4. BenchmarkParallelShardMapSet-8 5000000 395 ns/op

MIT License

  1. Copyright (c) 2016 Lyric