Skip to content
/ weakmap Public

A generic cache map implementation with weak pointers.

License

Notifications You must be signed in to change notification settings

acycl/weakmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weakmap

A generic cache map implementation with weak pointers as described on the Go blog.

Usage

To initialize a Map instance, provide a method for instantiating new values given a key.

m := Map[int, string]{
    New: func(key int) *string {
        value := strconv.Itoa(key)
        return &value
    },
}

k := 1
v := m.Load(k) // *v == "1"

Instances are safe for concurrent use but should not be copied.

About

A generic cache map implementation with weak pointers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages