Back to MemcachedStorage class

Method lockindex

protected bool
lockindex
()
Lock cache index
Returns
  • bool
Since
  • 3.0.0

Method lockindex - Source code

/**
 * Lock cache index
 *
 * @return  boolean
 *
 * @since   3.0.0
 */
protected function lockindex()
{
    $looptime = 300;
    $data_lock = static::$_db->add($this->_hash . '-index_lock', 1, 30);
    if ($data_lock === false) {
        $lock_counter = 0;
        // Loop until you find that the lock has been released.  that implies that data get from other thread has finished
        while ($data_lock === false) {
            if ($lock_counter > $looptime) {
                return false;
            }
            usleep(100);
            $data_lock = static::$_db->add($this->_hash . '-index_lock', 1, 30);
            $lock_counter++;
        }
    }
    return true;
}