11
Memoization in Go (en.wikipedia.org)

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?

you are viewing a single comment's thread
view the rest of the comments
[-] lyda@programming.dev 2 points 1 year ago

I suppose I should be clearer on the features I want. I'd want to be able to store my cache in memcached or redis and I want the cached data to expire. So for one call, I might want to keep it for five minutes, but another one can stick around for 24 hours.

The memorize package falls down there.

this post was submitted on 27 Sep 2023
11 points (100.0% liked)

Golang

1 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS