ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.92k stars 97 forks source link

Function results can set `FusionCacheEntryOptions.Duration` #23

Closed JoeShook closed 3 years ago

JoeShook commented 3 years ago

I have a use case where the returned data from a function passed to FusionCache contains the TTL (time to live), kind of like a DNS query answer. I would like to use that result to set the duration from calls like GetOrSetAsync .

I see MemoryOptionsModifier was something that might have been the way to go but the property is marked obsolete and not wired in.

Of course I can call TryGetAsync and then SetAsync in the meantime. @jodydonetti curious about your thoughts on this?

jodydonetti commented 3 years ago

I have a use case where the returned data from a function passed to FusionCache contains the TTL (time to live), kind of like a DNS query answer. I would like to use that result to set the duration from calls like GetOrSetAsync .

Yes, this is an absolutely reasonable requirement, so much so that other people alredy asked for it and is already in my backlog 😄 (see #17)

I see MemoryOptionsModifier was something that might have been the way to go but the property is marked obsolete and not wired in.

Yes, because it was an early experiment into that kind of feature, but the split between memory and distributed modifiers was not the greatest idea. Since I want to do something better, and the right design is not that straightforward, I postponed that decision and kept playing with different designs to strike the right balance.

I'm closing this since it is basically a duplicate of #17 but I hope to be able to have news on this feature quite soon!

JoeShook commented 3 years ago

This sounds great. I figured my request was buried inside one of the other issues. Thanks.

jodydonetti commented 3 years ago

Hi @JoeShook ! I've finally found some time to put down in words a couple of proposals for this here #24 ! I would be really interesed in knowing what you think.