Open
Description
Shortly I’ll be adding golang::last_version()
to get the latest stable version of Go from https://go.dev/dl/?mode=json.
I’m concerned about the potential to hit https://go.dev with too many requests (though it seems unlikely to me that this module will ever be used enough to cause a problem). So, I’m considering adding simple memoization to the function:
Puppet::Functions.create_function(:"golang::latest_version") do
# ...
def latest_version(url)
@@golang_latest_version_cache ||= {}
@@golang_latest_version_cache[url] ||= load_latest_version(url)
end
# ...
end
I imagine this will last longer than the catalog compilation, which seems like it might be an issue — if it lives as long as the Puppet server, then it could last quite a long time.
- I could add expiration to the cache.
- I’m not sure if there are other downsides I’m not seeing, or better ways to do this.
- Maybe this isn’t necessary at all?
Metadata
Metadata
Assignees
Labels
No labels