Well, you do that already. Except its having 1 goroutine per entry. Maybe 1 
goroutine for all would be enough.

On Tuesday 8 October 2024 at 21:07:22 UTC+2 Nico Braun wrote:

> 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/0e9f1d61-9e27-4f6c-8ec6-4c818e86d026n%40googlegroups.com.

Reply via email to