本文整理汇总了PHP中shm_remove函数的典型用法代码示例。如果您正苦于以下问题:PHP shm_remove函数的具体用法?PHP shm_remove怎么用?PHP shm_remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shm_remove函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
shm_remove($this->shmResource);
shm_detach($this->shmResource);
@unlink($this->tmpFileName);
unset($this->shmAdapter, $this->kvs);
}
开发者ID:adammbalogh,项目名称:key-value-store-shared-memory,代码行数:7,代码来源:AbstractKvsSharedMemoryTestCase.php
示例2: flush
/**
* Flush entire cache.
*/
function flush()
{
parent::flush();
// remove and reconnect to the SHM block
shm_remove($this->shmid);
$this->shmid = shm_attach($this->shmkey, $this->memsize, 0600);
}
示例3: destroy
public function destroy()
{
$nbProcess = $this->updateNbProcess(-1);
if ($nbProcess < 1) {
shm_remove($this->memory);
} else {
shm_detach($this->memory);
}
}
示例4: store
public static function store($key, $value)
{
self::getHandle();
if (!shm_put_var(self::$handle, self::getVarKey($key), $value)) {
sem_remove(self::$semaphore);
shm_remove(self::$handle);
die('couldn\'t write to shared memory.');
}
self::release();
}
示例5: remove
/**
* remove shared memory.
* you should know that it maybe does not work.
*
* @return bool
*/
public function remove()
{
//dallocate shared memory
if (!shm_remove($this->shm)) {
return false;
}
$this->dettach();
// shm_remove maybe not working. it likes a php bug.
unset($this->shm);
return true;
}
示例6: drop
public function drop()
{
try {
$shm = shm_attach($this->id, self::SEGMENT_SIZE, HESPER_IPC_PERMS);
} catch (BaseException $e) {
return false;
}
$result = shm_remove($shm);
shm_detach($shm);
return $result;
}
示例7: remove
public function remove()
{
if (!shm_remove($this->memory)) {
throw new StorageException("Could not release shared memory.");
}
$this->memory = null;
if (!sem_remove($this->semaphore)) {
throw new StorageException("Could not remove semaphore.");
}
$this->semaphore = null;
}
示例8: destroy
public function destroy()
{
if (!is_null($this->shm_res) && is_resource($this->shm_res)) {
shm_remove($this->shm_res);
if (file_exists($this->tmp_file)) {
unlink($this->tmp_file);
}
$this->shm_res = null;
$this->logger->debug('Delete shared memory resource');
}
}
示例9: __destruct
public function __destruct()
{
if ($this->changed) {
if (shm_put_var($this->res, self::DEFAULT_VAR_ID, $this->data) === false) {
$length = strlen($this->data);
shm_remove($this->res);
$this->res = shm_attach($this->id, ceil($length * 1.25));
shm_put_var($this->res, self::DEFAULT_VAR_ID, $this->data);
}
}
shm_detach($this->res);
}
示例10: teardown
public function teardown()
{
// Check shm validity before shm_get_var, return directly if NULL or FALSE
// This may happen when check_environment fail.
if ($this->shm) {
$lock = shm_get_var($this->shm, self::ADDRESS);
} else {
return;
}
// If this PID set this lock, release it
if ($lock['pid'] == $this->pid) {
shm_remove($this->shm);
shm_detach($this->shm);
}
}
示例11: getBadAddressList
/**
* 获取故障节点列表
* @return array
*/
public static function getBadAddressList($use_cache = true)
{
// 没有加载扩展
if (!extension_loaded('sysvshm')) {
self::$badAddressList = array();
return false;
}
// 还没有初始化故障节点
if (null === self::$badAddressList || !$use_cache) {
// 是否有故障节点
if (!shm_has_var(self::getShmFd(), RPC_BAD_ADDRESS_KEY2)) {
self::$badAddressList = array();
} else {
// 获取故障节点
$bad_address_list = shm_get_var(self::getShmFd(), RPC_BAD_ADDRESS_KEY2);
if (false === $bad_address_list || !is_array($bad_address_list)) {
// 出现错误,可能是共享内存写坏了,删除共享内存
$ret = shm_remove(self::getShmFd());
self::$badAddressShmFd = shm_attach(self::BAD_ASSRESS_LIST_SHM_KEY);
self::$badAddressList = array();
// 这个不要再加锁了
self::checkConfigMd5();
} else {
self::$badAddressList = $bad_address_list;
}
}
}
return self::$badAddressList;
}
示例12: getBadAddressList
/**
* 获取故障节点列表
* @return array
*/
public static function getBadAddressList($use_cache = true)
{
// 还没有初始化故障节点
if (null === self::$badAddressList || !$use_cache) {
$bad_address_list = array();
if (self::$shmEnable && shm_has_var(self::getShmFd(), self::SHM_BAD_ADDRESS_KEY)) {
// 获取故障节点
$bad_address_list = shm_get_var(self::getShmFd(), self::SHM_BAD_ADDRESS_KEY);
if (!is_array($bad_address_list)) {
// 可能是共享内寻写怀了,重新清空
self::getMutex();
shm_remove(self::getShmFd());
self::releaseMutex();
self::$badAddressShmFd = null;
self::$badAddressList = array();
} else {
self::$badAddressList = $bad_address_list;
}
} else {
self::$badAddressList = $bad_address_list;
}
}
return self::$badAddressList;
}
示例13: remove
public function remove()
{
shm_remove($this->shm_id);
return TRUE;
}
示例14: destroy
/**
* Force release
*/
public function destroy()
{
sem_remove($this->__mutex);
shm_remove($this->__shm);
}
示例15: Delete
function Delete()
{
if (!function_exists("shm_attach")) {
$this->ok = false;
return;
}
shm_remove($this->shmid);
shm_detach($this->shmid);
}