Hello. I found this very interesting.

I have some questions:

Have you considered the possibility of using *time.Duration* for the 
*maxTTL* parameter?
Maybe wouldn't it be more interesting if each item had its own *maxTTL* 
instead of just one for any item on the map?

If you'll allow me, I made those adaptations to your original code.
Here's the example: https://go.dev/play/p/rba6HCJe-4X

Thanks.


Em segunda-feira, 7 de outubro de 2024 às 16:37:53 UTC-3, Alex Pliutau 
escreveu:

> 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/a59272be-7277-4cb6-a7a7-8bf4bdcefc40n%40googlegroups.com.

Reply via email to