What does an Asynchronous ORM mean
What does an Asynchronous ORM really mean ? How does it differ in behaviour from a regular ORM ?
Where开发者_开发百科 can it be used ?
It means the calls to it return right away (doesn't block). You get the result at some later point in time, most likely due to a callback firing.
Something like this (pseudo-code):
function printResult(result)
if result is "foo" print "FOO" else print "BAR"
function fooBar()
Orm.myQuery().setCallback(printResult)
Orm.myOtherQuery().setCallback(printResult)
In this example, both queries would be executed at the same time (and the response from the second query could come before the first).
It is useful in a program that is uses non-blocking IO. Having queries execute at the same time, perhaps on multiple databases, is great latency wise. If each query takes 1 ms, doing 10 queries still just takes 1 ms, instead of 10 ms.
精彩评论