开发者

What does an Asynchronous ORM mean

开发者 https://www.devze.com 2022-12-14 21:44 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消