Open Edminsson opened 3 years ago
Hi, thanks for the issue. Steven Cleary's stuff is great and has been useful inspiration for LazyCache. LazyCache has always been fast enough for my needs as I only really cache things like slow database queries or api calls so this kind of micro-optimisation has not been meaningful in my use case. Now there are some benchmarks in the project, if you would like to submit a PR that shows a clear improvement I would be happy to review it?
Hi, It seems to me that AsyncLazy always runs the factory on the Thread Pool even when the factory contains IO-bound code. Perhaps I'm missing something but this does not seem very efficient. I believe Stephen Cleary has an implementation of AsyncLazy with a flag (AsyncLazyFlags.ExecuteOnCallingThread) that gives you the option to run the factory on the calling thread thread without calling Task.Factory.StartNew or Task.Run.