Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make Nested maps with concurrent Map? #69

Open
nishitm opened this issue Jul 18, 2018 · 2 comments
Open

How to make Nested maps with concurrent Map? #69

nishitm opened this issue Jul 18, 2018 · 2 comments
Labels

Comments

@nishitm
Copy link

nishitm commented Jul 18, 2018

For example,
In regular map

var data = map[string]map[string]string{}

data["a"] = map[string]string{}
data["b"] = make(map[string]string)
data["c"] = make(map[string]string)

data["a"]["w"] = "x"
data["b"]["w"] = "x"
data["c"]["w"] = "x"

How to do this kind of nested map using concurrent Map? Any Idea

@cookiebody
Copy link

You need to do type assertion with ConcurrentMap type to the nested concurrent map:

var data = cmap.New()
if v, ok := data.Get("key"); !ok {
  data.Set("nested_key", cmap.New())
} else {
  nested := v.(cmap.ConcurrentMap)
  nested.Set("key", "value")
}

@yunginnanet
Copy link

Has anyone done benchmarking with nested cmaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants