Why you probably shouldn't use INSERT DELAYED:
Starting with MySQL 5.6.6, INSERT DELAYED is deprecated and will be removed in a future release. Use INSERT (without DELAYED) instead.
( official documentation )
Symfony2 solution:
symfony2 , / kernel.terminate .
, . , .
:
namespace Acme\Your;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\HttpKernel\Event\KernelEvent;
class LongOperationLogger
{
protected $om;
protected $data;
public function __construct(ObjectManager $om)
{
$this->om = $om;
}
public function setData($data)
{
$this->data = $data;
}
public function onKernelTerminate(KernelEvent $event)
{
if ( null !== $this->data ) {
return;
}
$logEntry = new LogEntry('I will not block the response.', $this->data);
$this->om->persist($logEntry);
$this->om->flush();
}
}
-:
services:
long_operation.logger:
class: Acme\Your\LongOperationLogger
tags:
- { name: kernel.event_listener, event: kernel.terminate }
arguments: [ "@doctrine.orm.entity_manager" ]
, - , , , .
public function someAction()
{
$this->get('long_operation.logger')->setData($whatever)
}