While troubleshooting slow loading times in a project that uses file-based session storage I realized that php was locking the session file for each process that needed to read the session. My front-end logic was firing off multiple ajax calls to my Phalcon back end, but my Phalcon back end was forcing the ajax calls to queue up and wait turns to read the session file.
A quick fix for this would be to apply the "read_and_close"
option that php allows in the session_start()
command. Given that session_start()
is encapsulated within Phalcon's $session->start()
command, I would expect this syntax to work:
$session = new \Phalcon\Session\Adapter\Files;
$session->setOptions([ "read_and_close" => true ]);
$session->start();
Unfortunately, I could not find any documentation to indicate whether "read_and_close"
is implemented as a viable option within the \Phalcon\Session\Adapter\Files
class. Has anyone successfully used this option to remove session file blocking while using the \Phalcon\Session\Adapter\Files
class? If so, how did you go about making it work?