Hi, isnt this kind of inefficient? I think it would be better without 
tickers and extra goroutines. You could check if an item is expired when 
trying to fetch it. And then you do periodic compaction to make sure old 
stuff is freed up, eventually. 

On Monday 7 October 2024 at 21:37:53 UTC+2 Alex Pliutau wrote:

> In some cases your application doesn’t need Redis, and internal in-memory 
> map with locks and expiration will suffice.
>
> For example you already know the size of the map and you don’t need to 
> store a lot of data. Use cases could be IP rate limiting, or any other 
> short-lived data.
>
> Here is how you can implement this data structure in Go, let’s call it a 
> TTLMap:
>
> https://gist.github.com/plutov/69d22552c696d48496563529c624e0b7 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c9ee1cce-f35d-4800-bb45-e89c3055cb34n%40googlegroups.com.

Reply via email to