【发布时间】:2020-11-11 18:40:14
【问题描述】:
我在会话中使用Symfony 4.4 和 Redis。
我有一些控制器,我希望在向用户发送回复后更新后台数据库。
所以我写了这样的代码:
class GetCatController extends AbstractController
{
public function getCatController(LoggerInterface $logger, ManagerRegistry $doctrine, SessionInterface $session, ValidatorInterface $validator)
{
[...]
$replyToSend = new JsonResponse($reply, 200);
$replyToSend->send();
//My back ground activity like to do some query on the db.
[...]
return null;
}
但是我对会话有一些问题。
有没有更好的方法在回复用户之前创建和运行后台活动发送?
【问题讨论】: