/** * Unlock process * * @return Mage_Index_Model_Process */ public function unlock() { $this->_getSemIdentifier(); shm_remove_var($this->_shmId, $this->getIndexerCodeCrc()); @sem_release($this->_getSemIdentifier()); $this->_isLocked = false; }
/** * (non-PHPdoc) * @see Lexik\Bundle\MaintenanceBundle\Drivers.AbstractDriver::createUnlock() */ protected function createUnlock() { if ($this->shmId) { return shm_remove_var($this->shmId, self::VARIABLE_KEY); } return false; }
/** * {@inheritdoc} */ public function get() { if (shm_has_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID)) { $data = shm_get_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID); shm_remove_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID); return $data; } }
/** * Delete shared memory var */ public function del() { sem_acquire($this->__mutex); //block until released @shm_remove_var($this->__shm, $this->__key); sem_release($this->__mutex); //release mutex }
public function del($key) { if ($this->has($key)) { return shm_remove_var($this->shm, $this->shm_key($key)); } else { return false; } }
public function remove(string $key) : bool { if (isset($this->_cache[$key])) { unset($this->_cache[$key]); } $key = crc32($key); if (shm_has_var($this->_shmid, $key)) { return shm_remove_var($this->_shmid, $key); } else { return false; } }
/** * @param int $key * * @throws \Exception * @return $this * @author Yohann Marillet */ public function delete($key = 1) { $res = false; if ($this->has($key, true)) { $value = $this->get($key, true); $res = shm_remove_var($this->segment, $key); } if (!$res) { throw new \Exception('Cannot delete data in semaphore'); } return $this; }
public function unlink($key) { try { $shm = shm_attach($this->id, self::SEGMENT_SIZE, HESPER_IPC_PERMS); } catch (BaseException $e) { return false; } try { $result = shm_remove_var($shm, $key); } catch (BaseException $e) { // non existent key $result = false; } shm_detach($shm); return $result; }
/** * @param string $varName * @param mixed $value */ public function set($varName, $value) { $this->loadVars(); $varId = array_search($varName, $this->varNames); if (false === $varId) { shm_put_var($this->memory, count($this->varNames) + 2, $value); $this->varNames[] = $varName; if ($this->lock->lock()) { shm_put_var($this->memory, self::SID_VARS, $this->varNames); $this->lock->unlock(); } } else { if ($this->lock->lock()) { if (is_null($value)) { shm_remove_var($this->memory, $varId + 2); unset($this->varNames[$varId]); shm_put_var($this->memory, self::SID_VARS, $this->varNames); } else { shm_put_var($this->memory, $varId + 2, $value); } $this->lock->unlock(); } } }
/** * Delete data from storage * @param string $k * @return bool */ public function delete($k) { $key = $this->__hashcode($k); return @shm_remove_var($this->db, $key); }
public function destroy() { if (shm_has_var($this->shm, 1)) { shm_remove_var($this->shm, 1); } shm_remove($this->shm); }
/** * Deletes a cache entry. * * @param string $id cache id * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ public function delete($id) { return shm_remove_var($this->shmId, $this->forgeKey($id)); }
public function __unset($name) { $name = $this->intkey($name); shm_remove_var($this->ipc, $name); }
/** * (non-PHPdoc) * @see \parallely\TransportInterface::delete() */ public function delete($sId) { $this->_prepare(); $sId = crc32($sId); if (empty($this->_rShared) !== true and shm_has_var($this->_rShared, $sId) === true) { shm_remove_var($this->_rShared, $sId); } return $this; }
/** * @param $key * * @return bool */ public function delete($key) { return shm_remove_var(self::$shm_id, $key); }
/** * remove variable from memory * * @param string $name name of the variable * * @return bool true on success, false on fail * @access public */ function rm($name) { return shm_remove_var($this->_h, $this->_s2i($name)); }
/** * Removes a variable from shared memory. * * @param string $varName */ public function removeVar($varName) { $this->_registerVarName($varName); $useLocalMutex = !$this->_mutex->isAcquired(); if ($useLocalMutex) { $this->_mutex->acquire(); } $varKey = self::$_registeredVarLookup[$varName]; if (self::$_useSysV) { $res = shm_remove_var($this->_shmResource, $varKey); } else { $this->_readSharedData(); unset($this->_shmData[$varKey]); $res = $this->_writeSharedData(); } $this->addToVar('_varcount', -1); if ($useLocalMutex) { $this->_mutex->release(); } if (!$res) { throw new SharedMemoryException('Got error when attempting to remove shared variable "' . $varName . '".'); } }
/** * Removes a variable from the shared memory be specified key. * * @param string $key The key of variable * * @return bool True if the variable with key has been removed, otherwise false * * @see checkHandler * @see lock */ public function remove($key) { $this->checkHandle(); $this->lock(); $removed = false; if ($this->has($key)) { $removed = shm_remove_var($this->handle, $this->getIndex($key)); if ($removed) { $keys = $this->getHashKeys(); unset($keys[$key]); shm_put_var($this->handle, self::SHM_HASHKEYS_INDEX, $keys); } } $this->unlock(); return $removed; }
/** * (PHP 5 >= 5.0.0)<br/> * Offset to unset * @link http://php.net/manual/en/arrayaccess.offsetunset.php * * @param mixed $offset <p> * The offset to unset. * </p> * * @return void */ public function offsetUnset($offset) { $task = function () use($offset) { $keyMapper = $this->getKeyMap(); if (array_key_exists($offset, $keyMapper)) { shm_remove_var($this->id, $keyMapper[$offset]); unset($keyMapper[$offset]); shm_put_var($this->id, 0, $keyMapper); } }; $this->lockExecute($task); }
/** * Expire old entries. */ function gc() { $dict = $this->_get_dict(); foreach ($dict['keys'] as $k => $v) { if ($v['expire'] && $v['expire'] <= time()) { shm_remove_var($this->shmid, $v['varkey']); unset($dict['keys'][$k]); } } $this->_set_dict($dict); }
/** * Delete a KEY/VALUE from shm */ public function del($varkey) { // Remove a value from shm if ($this->mode == 'sysv') { return @shm_remove_var($this->id, $varkey); } else { if ($this->mode == 'shmop') { $curr = shmop_read($this->id, 0, shmop_size($this->id)); $curr = substr($curr, 0, strpos($curr, "")); $curr = $curr ? unserialize($curr) : array(); unset($curr[$varkey]); $curr = serialize($curr) . ""; return shmop_write($this->id, $curr, 0); } else { $curr = @file_get_contents($this->id); $curr = substr($curr, 0, strpos($curr, "")); $curr = $curr ? unserialize($curr) : array(); unset($curr[$varkey]); $curr = serialize($curr) . ""; return file_put_contents($this->id, $curr, LOCK_EX) or error('Unable to write file:' . $this->id, __FILE__, __LINE__); } } return false; }
<?php $settingMemKey = shm_attach(123456788); shm_remove_var($settingMemKey, 666666666);
function removekey() { if (!function_exists("shm_remove_var")) { $this->ok = false; return; } @shm_remove_var($this->shmid, $this->id); }
/** * Remove this segment's contents * * @return bool success * @throws io.IOException in case an error occurs */ public function remove() { $h = shm_attach($this->spot); $ret = shm_remove_var($h, $this->name); shm_detach($h); if (false === $ret) { throw new IOException('Could not remove segment ' . $this->name); } return $ret; }
public function delete($v3c6e0b8a9c15224a8228b9a98ca1531d) { $v3c6e0b8a9c15224a8228b9a98ca1531d = $this->transformKey($v3c6e0b8a9c15224a8228b9a98ca1531d); return shm_remove_var($this->segmentKey, $v3c6e0b8a9c15224a8228b9a98ca1531d); }
/** * Unsets a variable at the given offset * * @link http://php.net/manual/en/arrayaccess.offsetunset.php * @param int $offset The offset to unset. * @throws InvalidArgumentException * @return void */ public function offsetUnset($offset) { if (!array_key_exists($offset, $this->values)) { throw new InvalidArgumentException(sprintf('Undefined index "%s"')); } if (shm_remove_var($this->values[$offset]['shm'], $offset)) { unset($this->values[$offset]); } }
echo "failed\n"; exit(1); } $index = $ret; var_dump(shm_has_var($index, 1234)); shm_put_var($index, 1234, "test"); var_dump(shm_has_var($index, 1234)); $pid = pcntl_fork(); if ($pid == 0) { $ret = shm_attach($index); $ret = shm_get_var($index, 1234); if ($ret !== "test") { echo "oops\n"; exit(1); } shm_remove_var($index, 1234); shm_detach($index); exit(0); } // Verifying shm_remove_var worked, this is not sure test though. $ret = shm_get_var($index, 1234); for ($i = 0; $i < 1000; $i++) { if ($ret === false) { break; } usleep(1000); $ret = shm_get_var($index, 1234); } var_dump($ret === false); shm_remove($index); pcntl_waitpid($pid, $status);
/** * @param integer $key_ * * @return boolean */ public function remove($key_) { if (shm_has_var($this->m_segment, $key_)) { return shm_remove_var($this->m_segment, $key_); } return false; }
public function remove_var($varname, $autolock = FALSE) { $varkey = $this->_gen_key($varname); if ($autolock) { sem_acquire($this->sem); } if (!shm_has_var($this->shm_id, $varkey)) { $result = TRUE; } else { $result = shm_remove_var($this->shm_id, $varkey); } if ($autolock) { sem_release($this->sem); } return $result; }
function remove($key) { shm_remove_var($this->shm, $key); }