GithubHelp home page GithubHelp logo

isabella232 / concurrent-map Goto Github PK

View Code? Open in Web Editor NEW

This project forked from segment-boneyard/concurrent-map

0.0 0.0 0.0 23 KB

a thread-safe concurrent map for go

License: MIT License

Go 100.00%

concurrent-map's Introduction

concurrent map Circle CI

As explained here and here, the map type in Go doesn't support concurrent reads and writes. concurrent-map provides a high-performance solution to this by sharding the map with minimal time spent waiting for locks.

usage

Import the package:

import (
	"github.com/streamrail/concurrent-map"
)
go get "github.com/streamrail/concurrent-map"

The package is now imported under the "cmap" namespace.

example

	// Create a new map.
	map := cmap.New()
	
	// Sets item within map, sets "bar" under key "foo"
	map.Set("foo", "bar")

	// Retrieve item from map.
	if tmp, ok := map.Get("foo"); ok {
		bar := tmp.(string)
	}

	// Removes item under key "foo"
	map.Remove("foo")

For more examples have a look at concurrent_map_test.go.

Running tests:

go test "github.com/streamrail/concurrent-map"

templating

To generate your own custom concurrent maps please use concurrent_map_template.txt, the file is a base template for type specific maps, from terminal run:

sed 's/\<KEY\>/string/g' concurrent_map_template.go | sed 's/\<VAL\>/int/g' > cmap_string_int.go

This creates a new go source file for a string:int map.

license

MIT (see LICENSE file)

concurrent-map's People

Contributors

orcaman avatar icholy avatar karlseguin avatar swilly22 avatar janisz avatar minecrafter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.