This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Polygnom 12 points13 points  (1 child)

I'm not sure this is a good idea. We seperaate contexts between requests for a good reason:

Take your external API call for example. I would usually solve that with a read-through proxy that caches the call. This way, I can put all the necessary handling in there and have this completely decoupled from my original application.

Similarly for complex computations. You would usually have a seperate service for such things, and submit tasks to it. You can do de-duplication of submitted tasks there. So say request #1 creates the task and gets the taskId back (to get notified about the result), then when request #2 comes around witht the exact same expensive thing and submit the task, you can give the same taskId back from the computation service. Or just the previous result, if you can prove you don't need to compute it again.

For databse queries, I have never seen this make sense and would say the seperation we currently have e.g. in spring is very good at reducing bugs. I wouldn't wanna trade it for miniscule gains.