[go-nuts] Re: Map with expiration

2024-10-08 Thread Alex Pliutau
Yes, time.Duration and maybe another argument for ticker interval as time.Duration as well. On Wednesday, October 9, 2024 at 4:31:24 AM UTC+2 Cleberson Pedreira Pauluci wrote: > Hello. I found this very interesting. > > I have some questions: > > Have you considered the possibility of using *ti

Re: [go-nuts] Re: Map with expiration

2024-10-08 Thread Def Ceb
I've found this package to be useful for this in the past: https://github.com/jellydator/ttlcache On Wed, Oct 9, 2024, 04:31 Cleberson Pedreira Pauluci < pauluci.cleber...@gmail.com> wrote: > Hello. I found this very interesting. > > I have some questions: > > Have you considered the possibility

[go-nuts] Re: Map with expiration

2024-10-08 Thread Cleberson Pedreira Pauluci
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

[go-nuts] Re: Map with expiration

2024-10-08 Thread Nico Braun
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 P

[go-nuts] Re: Map with expiration

2024-10-08 Thread Alex Pliutau
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

[go-nuts] Re: Map with expiration

2024-10-08 Thread Nico Braun
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

[go-nuts] Re: Map with expiration

2024-10-08 Thread Nico Braun
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