english/libraries/joomla/cache/storage/memcache.php
/**
	 * Lock cached item - override parent as this is more efficient
	 *
	 * @param   string   $id        The cache data id
	 * @param   string   $group     The cache data group
	 * @param   integer  $locktime  Cached item max lock time
	 *
	 * @return  boolean  True on success, false otherwise.
	 *
	 * @since   11.1
	 */
Lock cached item - override parent as this is more efficient
@param   string   $id        The cache data id
@param   string   $group     The cache data group
@param   integer  $locktime  Cached item max lock time

@return  boolean  True on success, false otherwise.


Lock cached item - override parent as this is more efficient @param string $id The cache data id @param string $group The cache data group @param integer $locktime Cached item max lock time @return boolean True on success false otherwise .
public function lock($id,$group,$locktime)
	{
		$returning = new stdClass;
		$returning->locklooped = false;
		$looptime = $locktime * 10;
		$cache_id = $this->_getCacheId($id, $group);
		if (!$this->lockindex()) {
			return false;
		}
		$index = self::$_db->get($this->_hash.'-index');
		if ($index === false) {
			$index = array();
		}
		$tmparr = new stdClass;
		$tmparr->name = $cache_id;
		$tmparr->size = 1;
		$index[] = $tmparr;
		self::$_db->replace($this->_hash.'-index', $index , 0, 0);
		$this->unlockindex();
		$data_lock = self::$_db->add($cache_id.'_lock', 1, false, $locktime);
		if ($data_lock === FALSE) {
			$lock_counter = 0;
			while ($data_lock === FALSE) {
				if ($lock_counter > $looptime) {
						$returning->locked 		= false;
						$returning->locklooped 	= true;
					break;
				}
				usleep(100);
				$data_lock = self::$_db->add($cache_id.'_lock', 1, false, $locktime);
				$lock_counter++;
			}
		}
		$returning->locked = $data_lock;
		return $returning;
	}
public function lock ( $ id , $ group , $ locktime ) { $ returning = new stdClass ; $ returning -> locklooped = false ; $ looptime = $ locktime * 10 ; $ cache_id = $ this -> _getCacheId ( $ id , $ group ) ; if ( ! $ this -> lockindex ( ) ) { return false ; } $ index = self :: $ _db -> get ( $ this -> _hash . '-index' ) ; if ( $ index === false ) { $ index = array ( ) ; } $ tmparr = new stdClass ; $ tmparr -> name = $ cache_id ; $ tmparr -> size = 1 ; $ index [ ] = $ tmparr ; self :: $ _db -> replace ( $ this -> _hash . '-index' , $ index , 0 , 0 ) ; $ this -> unlockindex ( ) ; $ data_lock = self :: $ _db -> add ( $ cache_id . '_lock' , 1 , false , $ locktime ) ; if ( $ data_lock === FALSE ) { $ lock_counter = 0 ; while ( $ data_lock === FALSE ) { if ( $ lock_counter > $ looptime ) { $ returning -> locked = false ; $ returning -> locklooped = true ; break ; } usleep ( 100 ) ; $ data_lock = self :: $ _db -> add ( $ cache_id . '_lock' , 1 , false , $ locktime ) ; $ lock_counter ++ ; } } $ returning -> locked = $ data_lock ; return $ returning ; }
Lock cached item - override parent as this is more efficient
 @param   string   $id        The cache data id
 @param   string   $group     The cache data group
 @param   integer  $locktime  Cached item max lock time
Lock cached item - override parent as this is more efficient @param string $id The cache data id @param string $group The cache data group @param integer $locktime Cached item max lock time
// Loop until you find that the lock has been released. // That implies that data get from other thread has finished