A generic cache map implementation with weak pointers as described on the Go blog.
To initialize a Map instance, provide a method for instantiating new values
given a key.
m:=Map[int, string]{
New: func(keyint) *string {
value:=strconv.Itoa(key)
return&value
},
}
k:=1v:=m.Load(k) // *v == "1"Instances are safe for concurrent use but should not be copied.