Skip to content

LyricTian/cmap

Repository files navigation

Concurrent Map

A thread-safe map for the Go programming language.

License ReportCard GoDoc

Install

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

Usage

package main

import (
	"fmt"

	"github.com/LyricTian/cmap"
)

func main() {
	m := cmap.NewShardMap()
	// or
	// m := cmap.NewMap()
	m.Set("foo", "bar")
	if v, ok := m.Get("foo"); ok {
		fmt.Println("foo=", v.(string))
	}
	m.Remove("foo")
}

Benchmark

BenchmarkMapSet-8                	 1000000	      1032 ns/op
BenchmarkParallelMapSet-8        	 1000000	      1217 ns/op
BenchmarkShardMapSet-8           	 2000000	       854 ns/op
BenchmarkParallelShardMapSet-8   	 5000000	       395 ns/op

MIT License

Copyright (c) 2016 Lyric

About

A thread-safe map for the Go programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages