Reputation: 3126
I turned on memcached
on codeigniter
. It works fine but I noticed some delay on script execution. I debugged Session_memcached_driver and figured that it stuck for a few seconds on line 330-336
do
{
if ($this->_memcached->get($lock_key))
{
sleep(1);
continue;
}
if ( ! $this->_memcached->set($lock_key, time(), 300))
{
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
return FALSE;
}
$this->_lock_key = $lock_key;
break;
}
while (++$attempt < 30);
Obviously, it waiting for release and that takes a few seconds(5-7 seconds). Maybe I don't close something what I should or use CI session mechanism in wrong way? PHP 7, Linux, CI 3.1.4
Upvotes: 0
Views: 548
Reputation: 21
I had absulutely the same issue. Delay is caused by touch() command. If you look at driver line 109:
$this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, TRUE);
Comment out temporarily to see, if it solves issue. if YES, you need to update libmemcached on server. After upgrade, restart web server .
I had libmemcached 1.0.16, upgraded to 1.0.18 If you DONT upgrade, but just comment out that line, session time will NOT be extended upon user activity and will expire faster - as defined by config file.
Good luck!
Upvotes: 1