|
|
|
|
|
by maratd
5292 days ago
|
|
> it has session handler support so sessions are done completely in memory. It is unbelievably easy to build session support for other op-code caches. Here is my code for APC: if(extension_loaded('session'))
{
function ses_open($path, $name)
{
return TRUE;
}
function ses_close()
{
return TRUE;
}
function ses_read($id)
{
return (($GLOBALS['session'] = apc_fetch($id)) ? $GLOBALS['session'] : FALSE);
}
function ses_write($id, $data)
{
if(!isset($GLOBALS['session']) || $GLOBALS['session'] != $data)
{
if(apc_exists($id))
{
apc_delete($id);
}
return apc_store($id, $data);
}
else
{
return TRUE;
}
}
function ses_destroy($id)
{
unset($GLOBALS['session']);
return apc_delete($id);
}
function ses_gc($max)
{
if(
($apc = apc_sma_info())
&&
($apc['avail_mem'] / ($apc['num_seg'] * $apc['seg_size'])) < 0.25
)
{
return apc_clear_cache('user');
}
else
{
return TRUE;
}
}
ini_set('session.save_handler', 'user');
session_set_save_handler('ses_open', 'ses_close', 'ses_read', 'ses_write', 'ses_destroy', 'ses_gc');
}
The only problem is that this still requires you to compile the session extension. I am looking into ways of working around that, since it's not really used for anything except re-direction. |
|
eaccelerator's session handler (was) simply built in and requires no modification, just add the one-word setting to your php.ini