Reputation: 11270
When using session and namespaces, when do IO operations really occur (since sessions are stored as files somewhere on the server)?
As soon as I declare a new instance of *Zend_Session_Namespace*?
$myNamespace = new Zend_Session_Namespace('myNamespace');
As soon as I read or write into a variable of the namespace?
$myNamespace = new Zend_Session_Namespace('myNamespace');
$myNamespace->someVar = 3;
$myVar = $myNamespace->someVar;
I would like to know which operation is really expensive (IO read/write).
Upvotes: 1
Views: 111
Reputation: 8186
Zend_Session_Namespace act as a wrapper to $_SESSION .
$myNamespace = new Zend_Session_Namespace('myNamespace'); //write operation $_SESSION
$myNamespace->someVar = 3; //write operation on $_SESSION
$myVar = $myNamespace->someVar; // read operation on $_SESSION
but in all the cases read/write IO took place on RAM not on hardisk . When your application instance end's then only it gets written on hardisk.
Upvotes: 2
Reputation: 12420
Zend_Session_Namespace
uses native PHP sessions.
According the official PHP documentation:
When PHP shuts down (or when
session_write_close()
is called), PHP will internally encode the$_SESSION
superglobal and pass this along with the session ID to the the write callback. After the write callback has finished, PHP will internally invoke the close callback handler.
As you can read, the session is written when the script shuts down.
Upvotes: 3