ZiggyCreatures / FusionCache

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

🚀 Switch from Task<T> to ValueTask<T> #12

Closed jodydonetti closed 3 years ago

jodydonetti commented 3 years ago

A good way to reduce the amount of allocations would be to switch from Task<T> to ValueTask<T>.

In theory (and in practice, at least on a couple of projects where I tested it) there should be no change in code already using FusionCache, at least if that code is not doing something esoteric.

When calling async methods by using the standard await keyword the changes required are effectively none.

More info here https://blog.marcgravell.com/2019/08/prefer-valuetask-to-task-always-and.html , with the great Marc Gravell explaining everything way better than me.

Opinions?

jodydonetti commented 3 years ago

Current proof of concept in the branch /feature_valuetask .

jodydonetti commented 3 years ago

The switch has happened with v0.1.6 🎉