Ah you are right. I need to sleep. I read this code wrong, twice. Just 
ignore me. 

On Tuesday 8 October 2024 at 21:45:51 UTC+2 Alex Pliutau wrote:

> It's one goroutine for all currently. Which is more efficient than 
> checking each item individually.
>
> On Tuesday, October 8, 2024 at 9:10:16 PM UTC+2 Nico Braun wrote:
>
>> 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/f334b3fc-7005-438e-b587-b3896b89d044n%40googlegroups.com.

Reply via email to