当前位置: 首页>>代码示例>>PHP>>正文


PHP memcache_get_extended_stats函数代码示例

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


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

示例1: getUsage

 public function getUsage()
 {
     if (!function_exists('memcache_get_extended_stats')) {
         return false;
     }
     if ($this->usage === null) {
         $servers = DebugBar::getConfig('memcached');
         $server = array_shift($servers);
         $memcache = memcache_connect($server['host'], $server['port']);
         if ($memcache === false) {
             return false;
         }
         foreach ($servers as $server) {
             memcache_add_server($memcache, $server['host'], $server['port']);
         }
         $stats = memcache_get_extended_stats($memcache);
         $memory_used = 0;
         $memory_total = 0;
         foreach ($stats as $host => $usage) {
             $memory_used += $usage['bytes'];
             $memory_total += $usage['limit_maxbytes'];
             $this->usage[$host] = array('Version' => $usage['version'], 'Uptime' => $this->formatSeconds($usage['uptime']), 'Total memory' => $this->formatBytes($usage['limit_maxbytes']), 'Used memory' => $this->formatBytes($usage['bytes']), 'Available memory' => $this->formatBytes($usage['limit_maxbytes'] - $usage['bytes']), 'Threads / second' => $this->formatNum($usage['total_connections'] / $usage['uptime']), 'Current threads' => $usage['curr_connections'], 'Queries / second' => $this->formatNum($usage['cmd_get'] / $usage['uptime']), 'Hits' => $usage['get_hits'] . ' (' . $this->formatNum($usage['get_hits'] * 100 / $usage['cmd_get']) . '%)', 'Misses' => $usage['get_misses'] . ' (' . $this->formatNum($usage['get_misses'] * 100 / $usage['cmd_get']) . '%)', 'Inserts' => $usage['cmd_set'], 'Deletes' => $usage['delete_hits'], 'Items' => $usage['curr_items']);
         }
         $this->percent_used = $this->formatNum($memory_used * 100 / $memory_total);
     }
     return $this->usage;
 }
开发者ID:rubn-g,项目名称:debugbar,代码行数:27,代码来源:MemcachedPanel.php

示例2: reset

 /**
  *	Clear contents of cache backend
  *	@return bool
  *	@param $suffix string
  *	@param $lifetime int
  **/
 function reset($suffix = NULL, $lifetime = 0)
 {
     if (!$this->dsn) {
         return TRUE;
     }
     $regex = '/' . preg_quote($this->prefix . '.', '/') . '.+?' . preg_quote($suffix, '/') . '/';
     $parts = explode('=', $this->dsn, 2);
     switch ($parts[0]) {
         case 'apc':
             $info = apc_cache_info('user');
             foreach ($info['cache_list'] as $item) {
                 if (preg_match($regex, $item['info']) && $item['mtime'] + $lifetime < time()) {
                     apc_delete($item['info']);
                 }
             }
             return TRUE;
         case 'memcache':
             foreach (memcache_get_extended_stats($this->ref, 'slabs') as $slabs) {
                 foreach (array_filter(array_keys($slabs), 'is_numeric') as $id) {
                     foreach (memcache_get_extended_stats($this->ref, 'cachedump', $id) as $data) {
                         if (is_array($data)) {
                             foreach ($data as $key => $val) {
                                 if (preg_match($regex, $key) && $val[1] + $lifetime < time()) {
                                     memcache_delete($this->ref, $key);
                                 }
                             }
                         }
                     }
                 }
             }
             return TRUE;
         case 'wincache':
             $info = wincache_ucache_info();
             foreach ($info['ucache_entries'] as $item) {
                 if (preg_match($regex, $item['key_name']) && $item['use_time'] + $lifetime < time()) {
                     apc_delete($item['key_name']);
                 }
             }
             return TRUE;
         case 'xcache':
             return TRUE;
             /* Not supported */
         /* Not supported */
         case 'folder':
             if ($glob = @glob($parts[1] . '*')) {
                 foreach ($glob as $file) {
                     if (preg_match($regex, basename($file)) && filemtime($file) + $lifetime < time()) {
                         @unlink($file);
                     }
                 }
             }
             return TRUE;
     }
     return FALSE;
 }
开发者ID:Mumcio,项目名称:bookmark-manager,代码行数:61,代码来源:base.php

示例3: reset

 /**
  *	Clear contents of cache backend
  *	@return bool
  *	@param $suffix string
  *	@param $lifetime int
  **/
 function reset($suffix = NULL, $lifetime = 0)
 {
     if (!$this->dsn) {
         return TRUE;
     }
     $regex = '/' . preg_quote($this->prefix . '.', '/') . '.+?' . preg_quote($suffix, '/') . '/';
     $parts = explode('=', $this->dsn, 2);
     switch ($parts[0]) {
         case 'apc':
         case 'apcu':
             $info = apc_cache_info('user');
             if (!empty($info['cache_list'])) {
                 $key = array_key_exists('info', $info['cache_list'][0]) ? 'info' : 'key';
                 $mtkey = array_key_exists('mtime', $info['cache_list'][0]) ? 'mtime' : 'modification_time';
                 foreach ($info['cache_list'] as $item) {
                     if (preg_match($regex, $item[$key]) && $item[$mtkey] + $lifetime < time()) {
                         apc_delete($item[$key]);
                     }
                 }
             }
             return TRUE;
         case 'redis':
             $fw = Base::instance();
             $keys = $this->ref->keys($this->prefix . '.*' . $suffix);
             foreach ($keys as $key) {
                 $val = $fw->unserialize($this->ref->get($key));
                 if ($val[1] + $lifetime < time()) {
                     $this->ref->del($key);
                 }
             }
             return TRUE;
         case 'memcache':
             foreach (memcache_get_extended_stats($this->ref, 'slabs') as $slabs) {
                 foreach (array_filter(array_keys($slabs), 'is_numeric') as $id) {
                     foreach (memcache_get_extended_stats($this->ref, 'cachedump', $id) as $data) {
                         if (is_array($data)) {
                             foreach ($data as $key => $val) {
                                 if (preg_match($regex, $key) && $val[1] + $lifetime < time()) {
                                     memcache_delete($this->ref, $key);
                                 }
                             }
                         }
                     }
                 }
             }
             return TRUE;
         case 'wincache':
             $info = wincache_ucache_info();
             foreach ($info['ucache_entries'] as $item) {
                 if (preg_match($regex, $item['key_name']) && $item['use_time'] + $lifetime < time()) {
                     wincache_ucache_delete($item['key_name']);
                 }
             }
             return TRUE;
         case 'xcache':
             return TRUE;
             /* Not supported */
         /* Not supported */
         case 'folder':
             if ($glob = @glob($parts[1] . '*')) {
                 foreach ($glob as $file) {
                     if (preg_match($regex, basename($file)) && filemtime($file) + $lifetime < time()) {
                         @unlink($file);
                     }
                 }
             }
             return TRUE;
     }
     return FALSE;
 }
开发者ID:eghojansu,项目名称:moe,代码行数:76,代码来源:Cache.php

示例4: getExtendedStats

 /**
  * 缓存服务器池中所有服务器统计信息
  *
  * @param mixed $type 期望抓取的统计信息类型,可以使用的值有{reset, malloc, maps, cachedump, slabs, items, sizes}
  * @param mixed $slabid  cachedump命令会完全占用服务器通常用于 比较严格的调
  * @param mixed $limit 从服务端获取的实体条数
  */
 public function getExtendedStats($type = '', $slabid = 0, $limit = 100)
 {
     $re = memcache_get_extended_stats($this->memcache, $type, $slabid, $limit);
     return $re;
 }
开发者ID:shampeak,项目名称:ap.so,代码行数:12,代码来源:Mmc2.php


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