• 0 Posts
  • 29 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle

















  • wyrmroot@programming.devtoGolang@programming.devMemoization in Go
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    10 months ago

    In applications where I’ve needed this, I’ve taken a manual approach. Structure the function to return a single Result struct (including an error field), develop a convention for mapping function inputs to a string, then add reads & writes to a map[string]*Result which allows me to return cached values as a shortcut. No idea if it’s the most efficient way, I’ve not actually considered finding a package to handle the process.

    Edit: For more advanced behavior, what are your thoughts on the official memoize package?