3 ms·
Show HN: TtlMap: A Golang map in which entries expire after given a time period
- user- 3y agoWhat can this be used for?
- jftuga 3y agoIt can be used to keep the size of your map small by removing items that may no longer be needed because they have not been accessed. Ideally, if a key value is not in the map (but needs to be), it can be computed again and then placed back into the map with possibly an updated value for the given key.
- Ajnasz 3y agoIt might be useful for you that, in Go, maps do not shrink their memory usage when elements are deleted. [1]https://vivasoftltd.com/golang-mistakes-1-maps-and-memory-leaks/ https://vivasoftltd.com/golang-mistakes-1-maps-and-memory-le... [2]https://medium.com/@quicktechlearn/maps-and-memory-leaks-in-golang-4638bdc952b9 https://medium.com/@quicktechlearn/maps-and-memory-leaks-in-...