, Action.async, , . , API .
Play 2.2, , , Play 2.3 . Action.apply Action.async . Action.async , Future[Result], Action.apply , Result. Action.apply , block: => Result Future[Result] Future.successful(block). ( , Future.successful, .)
, API. , JDBC vs ScalikeJDBC-async, API . , json.
JDBC ( ):
def read(id: Long): User
:
def read(id: Long) = Action {
Ok(Json.toJson(User.read(id))
}
, Action.apply :
def read(id: Long) = Action.async {
Future.successful(Ok(Json.toJson(User.read(id)))
}
User.read - JDBC, , .
, , :
def read(id: Long): Future[User]
:
def read(id: Long) = Action.async {
User.read(id).map(user => Ok(Json.toJson(user)))
}
API, Future s. API. API (, JDBC), . Play : https://groups.google.com/forum/#!topic/play-framework/WWQ0HeLDOjg