• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP shm_get_var函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中shm_get_var函数的典型用法代码示例。如果您正苦于以下问题:PHP shm_get_var函数的具体用法?PHP shm_get_var怎么用?PHP shm_get_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了shm_get_var函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * @param integer $key_
  *
  * @return mixed
  */
 public function get($key_)
 {
     if (false === shm_has_var($this->m_segment, $key_)) {
         return null;
     }
     return shm_get_var($this->m_segment, $key_);
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.runtime,代码行数:12,代码来源:shm.php


示例2: fetch

 /**
  * Fetches an entry from the cache.
  *
  * @param string $id cache id The id of the cache entry to fetch.
  * @return mixed The cached data or FALSE, if no cache entry exists for the given id.
  */
 public function fetch($id)
 {
     if ($this->contains($id)) {
         return shm_get_var($this->shmId, $this->forgeKey($id));
     }
     return false;
 }
开发者ID:jiangtong1125,项目名称:Zebra-Multi-Process,代码行数:13,代码来源:SHMCache.php


示例3: read

 public function read($key)
 {
     if ($this->shmId) {
         return @shm_get_var($this->shmId, $key);
     }
     return false;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:7,代码来源:ShmSemaphorBucket.php


示例4: generate

 /**
  * @return IdValue
  */
 public function generate()
 {
     $timestamp = $this->generateTimestamp();
     // Acquire semaphore
     $semaphore = sem_get($this->semaphoreId);
     sem_acquire($semaphore);
     // Attach shared memory
     $memory = shm_attach(self::SHM_KEY);
     $sequence = 0;
     if (!is_null($this->lastTimestamp) && $timestamp->equals($this->lastTimestamp)) {
         // Get
         $sequence = shm_get_var($memory, self::SHM_SEQUENCE) + 1 & $this->config->getSequenceMask();
         // Increment sequence
         shm_put_var($memory, self::SHM_SEQUENCE, $sequence);
         if ($sequence === 0) {
             usleep(1000);
             $timestamp = $this->generateTimestamp();
         }
     } else {
         // Reset sequence if timestamp is different from last one.
         $sequence = 0;
         shm_put_var($memory, self::SHM_SEQUENCE, $sequence);
     }
     // Detach shared memory
     shm_detach($memory);
     // Release semaphore
     sem_release($semaphore);
     // Update lastTimestamp
     $this->lastTimestamp = $timestamp;
     return new IdValue($timestamp, $this->regionId, $this->serverId, $sequence, $this->calculate($timestamp, $this->regionId, $this->serverId, $sequence));
 }
开发者ID:ada-u,项目名称:chocoflake,代码行数:34,代码来源:IdWorkerOnSharedMemory.php


示例5: _get

 /**
  * Private helper function
  *
  * @return  var data
  */
 protected function _get()
 {
     $h = shm_attach($this->spot);
     $data = shm_get_var($h, $this->name);
     shm_detach($h);
     return is_array($data) ? $data : false;
 }
开发者ID:xp-framework,项目名称:core,代码行数:12,代码来源:ShmSegment.class.php


示例6: set

 public function set($key, $value, $no_cas = false)
 {
     if (!$this->isOpen()) {
         $this->open();
     }
     $this->enterCriticalSection($this->ipckey);
     $this->debug("SHM set: {$key} = {$value}");
     $key = strtolower($key);
     $idx = $this->props[$key];
     if (!$no_cas && shm_has_var($this->shm, $idx) && !empty($this->hashes[$key])) {
         $var = shm_get_var($this->shm, $idx);
         $check = md5($var);
         if ($this->hashes[$key] == $check) {
             $this->debug("CAS check: Key not modified: {$key}");
             shm_put_var($this->shm, $idx, $value);
             $ok = true;
         } else {
             $this->debug("CAS check: Key modified, write blocked: {$key}");
             $ok = false;
         }
     } else {
         $this->debug("CAS check: Check disabled for set: {$key}");
         $ok = true;
         shm_put_var($this->shm, $idx, $value);
     }
     if ($ok) {
         $hash = md5($value);
         $this->hashes[$key] = $hash;
         $this->debug("CAS hash for {$key} is now {$hash}");
     }
     $this->leaveCriticalSection();
     return $ok;
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:33,代码来源:ipcsharedobject.php


示例7: retrieve

 public static function retrieve($key)
 {
     self::getHandle();
     $data = shm_get_var(self::$handle, self::getVarKey($key));
     self::release();
     return $data;
 }
开发者ID:mikejw,项目名称:elib-base,代码行数:7,代码来源:Stats.php


示例8: getNextValueByShareMemory

/**
 * 通过本机共享内存件来生成一个auto_increment序列
 *
 * 序列类似MySQL的auto_increment
 *
 * @access private
 * @param  void
 * @return mixed
 */
function getNextValueByShareMemory()
{
    $addr = '127.0.0.1';
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $addr = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif (!empty($_SERVER['SERVER_ADDR'])) {
        $addr = $_SERVER['SERVER_ADDR'];
    }
    $skey = 'global_serial_generator_seed_' . $addr;
    $ikey = crc32($skey);
    $sem = $shm = null;
    $retry_times = 1;
    do {
        $sem = sem_get($ikey, 1, 0777);
        $shm = shm_attach($ikey, 128, 0777);
        if (is_resource($sem) && is_resource($shm)) {
            break;
        }
        $cmd = "ipcrm -M 0x00000000; ipcrm -S 0x00000000; ipcrm -M {$ikey} ; ipcrm -S {$ikey}";
        $last_line = exec($cmd, $output, $retval);
    } while ($retry_times-- > 0);
    if (!sem_acquire($sem)) {
        return false;
    }
    $next_value = false;
    if (shm_has_var($shm, $ikey)) {
        shm_put_var($shm, $ikey, $next_value = shm_get_var($shm, $ikey) + 1);
    } else {
        shm_put_var($shm, $ikey, $next_value = 1);
    }
    $shm && shm_detach($shm);
    $sem && sem_release($sem);
    return $next_value;
}
开发者ID:fixbugs,项目名称:pubfunc-php,代码行数:43,代码来源:pub.serial.php


示例9: Map2GE

function Map2GE($x, $y)
{
    if (0) {
        $SHM_KEY = ftok(__FILE__, chr(4));
        $data = shm_attach($SHM_KEY, 102400, 0666);
        $result = shm_get_var($data, 1);
        $r = $result[$x][$y];
        if (isset($r)) {
            shm_detach($data);
            return $r;
        }
    }
    // ­×¥¿
    $r = t67to97($x, $y);
    $x = $r[0];
    $y = $r[1];
    $proj = "proj -I +proj=tmerc +ellps=aust_SA +lon_0=121 +x_0=250000 +k=0.9999";
    $ret = shell_exec("echo {$x} {$y} | {$proj}");
    if (preg_match("/(\\d+)d(\\d+)'([\\d.]+)\"E\\s+(\\d+)d(\\d+)'([\\d.]+)\"N/", $ret, $matches)) {
        list($junk, $ed, $em, $es, $nd, $nm, $ns) = $matches;
        $r[0] = $ed + $em / 60 + $es / 3600;
        $r[1] = $nd + $nm / 60 + $ns / 3600;
        if (0) {
            $result[$x][$y] = $r;
            shm_put_var($data, 1, $result);
            shm_detach($data);
        }
        return $r;
    }
    return FALSE;
    // exit;
}
开发者ID:KevinStoneCode,项目名称:twmap,代码行数:32,代码来源:kml_lib.php


示例10: DUMP

 public function DUMP()
 {
     if (!$this->ok) {
         return array();
     }
     $data = @shm_get_var($this->shmid, $this->index);
     return $data;
 }
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:8,代码来源:class.semaphores.php


示例11: __get

 public function __get($k)
 {
     $key = crc32($k);
     if (!shm_has_var($this->sharedMemoryId, $key)) {
         return null;
     }
     return shm_get_var($this->sharedMemoryId, $key);
 }
开发者ID:xingcuntian,项目名称:MultiPhreading,代码行数:8,代码来源:Threading.php


示例12: __get

 public function __get($var)
 {
     if (shm_has_var($this->fsh, $var)) {
         return shm_get_var($this->fsh, $var);
     } else {
         return null;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:bincache.php


示例13: execute

 /**
  * Execution commands.
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (is_null(Config::$sharedId) == false && @shm_has_var(Config::$sharedId, Config::STATUS)) {
         $output->writeln('<info>' . shm_get_var(Config::$sharedId, Config::STATUS) . '</info>');
     } else {
         $output->writeln('<comment>' . Config::NAME . ' not running</comment>');
     }
 }
开发者ID:dmamontov,项目名称:symfony-phpcron,代码行数:13,代码来源:StatusCommand.php


示例14: get

 /**
  * @param $key
  * @param int $size
  * @return mixed
  */
 public function get($key, $size = 10000)
 {
     $result = $this->attach($key, $size);
     sem_acquire($result['mutex']);
     $value = @shm_get_var($result['shm'], $key);
     sem_release($result['mutex']);
     return $value;
 }
开发者ID:bes89,项目名称:sharedmemory,代码行数:13,代码来源:SharedMemory.php


示例15: __get

 public function __get($name)
 {
     $name = $this->intkey($name);
     if (shm_has_var($this->ipc, $name)) {
         return shm_get_var($this->ipc, $name);
     }
     return NULL;
 }
开发者ID:Victopia,项目名称:prefw,代码行数:8,代码来源:SharedMemory.php


示例16: get

 public function get($key)
 {
     if ($this->has($key)) {
         return shm_get_var($this->shm, $this->shm_key($key));
     } else {
         return false;
     }
 }
开发者ID:millken,项目名称:ypf,代码行数:8,代码来源:Shm.php


示例17: get

 /**
  * {@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;
     }
 }
开发者ID:vatson,项目名称:isolated-callback,代码行数:11,代码来源:SharedMemory.php


示例18: get

 /**
  * Gets the value of the semaphore
  * @author Yohann Marillet
  */
 public function get($key = 1)
 {
     $return = false;
     if ($this->has($key, true)) {
         $return = shm_get_var($this->segment, $key)[0];
     }
     return $return;
 }
开发者ID:ymarillet,项目名称:sknife,代码行数:12,代码来源:SemaphoreShm.php


示例19: execute

 /**
  * Execution commands.
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (is_null(Config::$sharedId) == false && @shm_has_var(Config::$sharedId, Config::PID)) {
         $process = new Process('ps o pid --ppid ' . shm_get_var(Config::$sharedId, Config::PID));
         $process->run();
     } else {
         $output->writeln('<comment>' . Config::NAME . ' not running</comment>');
     }
 }
开发者ID:dmamontov,项目名称:symfony-phpcron,代码行数:14,代码来源:CancelCommand.php


示例20: containsKey

 function containsKey($key)
 {
     if (!is_numeric($key)) {
         throw new Scalr_System_Exception(sprintf("key must be numeric. '%s' is given", $key));
     }
     // `shm_get_var` generates PHP warning if key doesn't exists
     $value = @shm_get_var($this->shm, $key);
     return $value !== false;
 }
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:9,代码来源:Shm.php



注:本文中的shm_get_var函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP shm_has_var函数代码示例发布时间:2022-05-24
下一篇:
PHP shm_detach函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap