I’m curious what people are doing for memoization in #golang. I’ve looked around and haven’t found great libraries for this which makes me wonder if I’m pursuing the wrong solution to a problem.

Caching the return values of functions based on the params has been useful to reduce load on downstream services, make things a bit faster on average and even add some level of consistency in functions that can be highly variable (which is an odd use case but nonethelass useful). But maybe there’s a different pattern/idiom that’s used in the Go ecosystem?

  • kamstrup@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Pet peeve: don’t use string keys. It invites key collision errors. Use the fact Go supports structs as keys in maps. Safer and more efficient.