ZiggyCreatures / FusionCache

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

[FEATURE] 🪞 Remove all usage of reflection #197

Closed jodydonetti closed 8 months ago

jodydonetti commented 9 months ago

Problem

Not technically a problem per se, but with the release of the new and improved auto-recovery in v0.24.0, I had to add a little bit of reflection usage to support a complex scenario of recovering some of the transient distributed errors scenarios.

Solution

I'd like to look back at that code and find a way remove reflection, mainly to:

jodydonetti commented 9 months ago

Hi all, I just released v1.0.0-preview1 🥳

Please try it out so we can spot any potential issue before the official v1.0, thanks!

celluj34 commented 9 months ago

I see some usages of lock in the code, have you though about using Lazy<T> where possible? For example, FusionCache.cs / AutoRecovery uses a lock to generate if it doesn't exist, would it be more performance to use a lockless style instead?

jodydonetti commented 9 months ago

Hi @celluj34 , I think it has an overhead over a simple double-checked lock, but I'll try asap and will let you know.

Anyway, take a look at Lazy<T> implementation...

celluj34 commented 9 months ago

Oh lol I never knew it used a lock under the hood. Well nevermind then! I always thought Lazy was a good way to avoid locks in app code since they are blocking, but I guess it's locks all the way down...

jodydonetti commented 9 months ago

Hi all, I just released preview2 🥳

Please give it a try, thanks!

jodydonetti commented 8 months ago

Hi all, I've finally released v1.0 🥳

Feels a little unreal tbh, but yep: v1.0 is out.