當前位置: 首頁>>代碼示例>>PHP>>正文


PHP shmop_size函數代碼示例

本文整理匯總了PHP中shmop_size函數的典型用法代碼示例。如果您正苦於以下問題:PHP shmop_size函數的具體用法?PHP shmop_size怎麽用?PHP shmop_size使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了shmop_size函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: send

 /**
  * Writes a message to the shared memory.
  *
  * @param mixed   $message The message to send
  * @param integer $signal  The signal to send afterward
  * @param integer $pause   The number of microseconds to pause after signalling
  */
 public function send($message, $signal = null, $pause = 500)
 {
     $messageArray = array();
     if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
         // Read any existing messages in shared memory
         $readMessage = shmop_read($shmId, 0, shmop_size($shmId));
         $messageArray[] = unserialize($readMessage);
         shmop_delete($shmId);
         shmop_close($shmId);
     }
     // Add the current message to the end of the array, and serialize it
     $messageArray[] = $message;
     $serializedMessage = serialize($messageArray);
     // Write new serialized message to shared memory
     $shmId = shmop_open($this->pid, 'c', 0644, strlen($serializedMessage));
     if (!$shmId) {
         throw new ProcessControlException(sprintf('Not able to create shared memory segment for PID: %s', $this->pid));
     } else {
         if (shmop_write($shmId, $serializedMessage, 0) !== strlen($serializedMessage)) {
             throw new ProcessControlException(sprintf('Not able to write message to shared memory segment for segment ID: %s', $shmId));
         }
     }
     if (false === $signal) {
         return;
     }
     $this->signal($signal ?: $this->signal);
     usleep($pause);
 }
開發者ID:edwardstock,項目名稱:spork,代碼行數:35,代碼來源:SharedMemory.php

示例2: size

 public function size()
 {
     if (null === $this->shmSize) {
         $this->shmSize = shmop_size($this->shmID);
     }
     return $this->shmSize;
 }
開發者ID:panlatent,項目名稱:easy-shm,代碼行數:7,代碼來源:Shm.php

示例3: size

 public function size()
 {
     if ($this->status == self::STATUS_OPENED) {
         return shmop_size($this->shmId);
     }
     return 0;
 }
開發者ID:dan-homorodean,項目名稱:falx-concurrency-and-ipc,代碼行數:7,代碼來源:Handle.php

示例4: get

 /**
  * 讀取緩存
  * 
  * @access public
  * @param string $name
  *            緩存變量名
  * @return mixed
  */
 public function get($name = false)
 {
     N('cache_read', 1);
     $id = shmop_open($this->handler, 'c', 0600, 0);
     if ($id !== false) {
         $ret = unserialize(shmop_read($id, 0, shmop_size($id)));
         shmop_close($id);
         if ($name === false) {
             return $ret;
         }
         $name = $this->options['prefix'] . $name;
         if (isset($ret[$name])) {
             $content = $ret[$name];
             if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
                 // 啟用數據壓縮
                 $content = gzuncompress($content);
             }
             return $content;
         } else {
             return null;
         }
     } else {
         return false;
     }
 }
開發者ID:siimanager,項目名稱:sii,代碼行數:33,代碼來源:Shmop.class.php

示例5: delete

 /**
  * Mark a shared memory block for deletion.
  *
  * @return bool
  */
 public function delete()
 {
     /*
      * Bug fix
      * @link https://bugs.php.net/bug.php?id=71921
      */
     shmop_write($this->shmid, str_pad('', shmop_size($this->shmid), ' '), 0);
     return shmop_delete($this->shmid);
 }
開發者ID:anime-db,項目名稱:shmop,代碼行數:14,代碼來源:FixedBlock.php

示例6: MonInit

 function MonInit()
 {
     $this->{$shm_id} = shmop_open(0xff3, "c", 0644, 1024);
     if (!$this->{$shm_id}) {
         debug("No se pudo crear el segmento de memoria compartida\n", "red");
     }
     // Obtencion del tamaño del segmento de memoria compartida
     $shm_size = shmop_size($this->{$shm_id});
     debug("Segmento de memoria: se han reservado " . $shm_size . " bytes.\n", "blue");
 }
開發者ID:BackupTheBerlios,項目名稱:ascore,代碼行數:10,代碼來源:lib_monitor.php

示例7: getCallbackParams

 public function getCallbackParams()
 {
     $shmId = @shmop_open($this->pid, 'a', 0644, 0);
     if (empty($shmId)) {
         return false;
     }
     $datas = unserialize(shmop_read($shmId, 0, shmop_size($shmId)));
     shmop_delete($shmId);
     shmop_close($shmId);
     return $datas;
 }
開發者ID:Lith,項目名稱:nofussframework,代碼行數:11,代碼來源:Task.php

示例8: get

 function get($key)
 {
     $this->shmop_key = ftok($this->pre . $key);
     //Linux/Unix Only
     $this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
     if ($this->shmop_id === false) {
         return false;
     }
     $data = shmop_read($this->shmop_id, 0, shmop_size($this->shmop_id));
     shmop_close($this->shmop_id);
     return function_exists('gzuncompress') ? gzuncompress($data) : $data;
 }
開發者ID:hcd2008,項目名稱:destoon,代碼行數:12,代碼來源:cache_shmop.class.php

示例9: __destruct

 public function __destruct()
 {
     if ($this->changed) {
         $serialized = serialize($this->data);
         if (strlen($serialized) > shmop_size($this->res)) {
             shmop_delete($this->res);
             $this->res = shmop_open($id, 'c', 0644, ceil(strlen($serialized) * 1.25));
         }
         shmop_write($this->res, $serialized, 0);
     }
     shmop_close($this->res);
 }
開發者ID:wapmorgan,項目名稱:kvstorage,代碼行數:12,代碼來源:Shmop.php

示例10: deletemem

 public function deletemem($shmkey)
 {
     $size = shmop_size($shmkey);
     if ($size > 0) {
         $this->updatestats($size, "del");
     }
     if (!shmop_delete($shmkey)) {
         shmop_close($shmkey);
         return false;
     } else {
         shmop_close($shmkey);
         return true;
     }
 }
開發者ID:glial,項目名稱:glial,代碼行數:14,代碼來源:Shmop.php

示例11: stream_read

 function stream_read($count)
 {
     if ($this->body === NULL) {
         $this->id = ftok($this->path, 'M');
         $shm = @shmop_open($this->id, 'a', 0, 0);
         if ($shm) {
             $this->body = shmop_read($shm, 0, shmop_size($shm));
         } else {
             $this->body = file_get_contents($this->path);
         }
     }
     $ret = substr($this->body, $this->position, $count);
     $this->position += strlen($ret);
     return $ret;
 }
開發者ID:tombouctou,項目名稱:quicky,代碼行數:15,代碼來源:memory_cache.class.php

示例12: __destruct

 public function __destruct()
 {
     if ($this->db) {
         $last = STORAGE_PATH . DS . 'memory' . sha1($this->ns . $this->entity) . '.last';
         $size = STORAGE_PATH . DS . 'memory' . sha1($this->ns . $this->entity) . '.dbsize';
         $age = time() - filemtime($last);
         if ($age >= 900) {
             File::delete($last);
             File::create($last);
             $this->write();
         }
         File::delete($size);
         File::put($size, shmop_size($this->db));
         shmop_close($this->db);
     }
 }
開發者ID:noikiy,項目名稱:inovi,代碼行數:16,代碼來源:Fastdb.php

示例13: readAndDelete

 /**
  * read data and delete shared memory
  *
  * @return  mix
  * @throws  RuntimeException
  */
 public function readAndDelete()
 {
     $s = shmop_open($this->genKey(), 'a', 0, 0);
     if ($s === false) {
         throw new RuntimeException('could not open shared memory');
     }
     $data = shmop_read($s, 0, shmop_size($s));
     shmop_close($s);
     try {
         $this->delete();
     } catch (RuntimeException $e) {
         throw $e;
     }
     $unserialized = unserialize($data);
     return $unserialized['data'];
 }
開發者ID:TomoakiNagahara,項目名稱:snidel,代碼行數:22,代碼來源:Data.php

示例14: read

 /**
  * @todo fix mixed return types!
  * @return string|null
  */
 public function read()
 {
     if (!$this->exists()) {
         return null;
     }
     $shmId = @shmop_open($this->shmKey, 'w', 0, 0);
     if (!$shmId) {
         return null;
     }
     $size = @shmop_size($shmId);
     if (!$size) {
         return null;
     }
     $data = @shmop_read($shmId, 0, $size);
     @shmop_close($shmId);
     return (string) $data;
 }
開發者ID:sgc-fireball,項目名稱:libphp,代碼行數:21,代碼來源:SHM.php

示例15: isLocked

 /**
  * Check if process is locked
  *
  * @return bool
  */
 public function isLocked()
 {
     if (0 === $this->getIndexerId()) {
         Mage::throwException('FastIndexer: IndexerId cannot be 0');
     }
     if (null !== $this->_isLocked) {
         return $this->_isLocked;
     }
     $shmId = @shmop_open($this->getIndexerId(), 'a', self::PERM, self::LEN);
     if (false === $shmId) {
         $this->_isLocked = false;
         return $this->_isLocked;
     }
     $size = shmop_size($shmId);
     $startTime = shmop_read($shmId, 0, $size);
     shmop_close($shmId);
     $this->_isLocked = $this->_isLockedByTtl((double) $startTime);
     return $this->_isLocked;
 }
開發者ID:ThomasNegeli,項目名稱:Magento-FastIndexer,代碼行數:24,代碼來源:Shmop.php


注:本文中的shmop_size函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。