コード例 #1
0
ファイル: APCU.php プロジェクト: techart/tao
 public function get_all_keys()
 {
     $info = apcu_cache_info();
     $list = array();
     foreach ($info['cache_list'] as $cl) {
         $list[] = $cl['key'];
     }
     return $list;
 }
コード例 #2
0
ファイル: M6WebGuzzleHttp.php プロジェクト: m6web/apcu-bundle
 /**
  * {@inheritDoc}
  */
 public function ttl($key)
 {
     $key = $this->getFinalKey($key);
     $infos = apcu_cache_info();
     foreach ($infos['cache_list'] as $entry) {
         if ($entry['info'] == $key) {
             return $entry['ttl'];
         }
     }
     return false;
 }
コード例 #3
0
ファイル: ApcuCache.php プロジェクト: Briareos/Undine
 /**
  * {@inheritdoc}
  */
 protected function doGetStats()
 {
     $info = apcu_cache_info('', true);
     $sma = apcu_sma_info();
     // @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
     if (PHP_VERSION_ID >= 50500) {
         $info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'];
         $info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'];
         $info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime'];
     }
     return array(Cache::STATS_HITS => $info['num_hits'], Cache::STATS_MISSES => $info['num_misses'], Cache::STATS_UPTIME => $info['start_time'], Cache::STATS_MEMORY_USAGE => $info['mem_size'], Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem']);
 }
コード例 #4
0
ファイル: apcu.php プロジェクト: vdwijngaert/wp-ffpc
 /**
  * init apcu backend: test APCu availability and set alive status
  */
 protected function _init()
 {
     /* verify apcu functions exist, apcu extension is loaded */
     if (!function_exists('apcu_cache_info')) {
         $this->log(__translate__('APCu extension missing', 'wp-ffpc'));
         return false;
     }
     /* verify apcu is working */
     if (@apcu_cache_info("user") != false) {
         $this->log(__translate__('backend OK', 'wp-ffpc'));
         $this->alive = true;
     }
 }
コード例 #5
0
ファイル: ApcuTest.php プロジェクト: derrabus/polyfill
 public function testApcu()
 {
     $key = __CLASS__;
     apcu_delete($key);
     $this->assertFalse(apcu_exists($key));
     $this->assertTrue(apcu_add($key, 123));
     $this->assertTrue(apcu_exists($key));
     $this->assertSame(array($key => -1), apcu_add(array($key => 123)));
     $this->assertSame(123, apcu_fetch($key));
     $this->assertTrue(apcu_store($key, 124));
     $this->assertSame(124, apcu_fetch($key));
     $this->assertSame(125, apcu_inc($key));
     $this->assertSame(124, apcu_dec($key));
     $this->assertTrue(apcu_cas($key, 124, 123));
     $this->assertFalse(apcu_cas($key, 124, 123));
     $this->assertTrue(apcu_delete($key));
     $this->assertFalse(apcu_delete($key));
     $this->assertArrayHasKey('cache_list', apcu_cache_info());
 }
コード例 #6
0
ファイル: ApcWrapper.php プロジェクト: dan-lyn/apcwrapper
 /**
  * Get all the keys currently in the cache.
  * @see apc_cache_info()
  *
  * @return array
  */
 public function getKeys()
 {
     $cache = false;
     $key = false;
     $keys = array();
     if (function_exists('apcu_cache_info')) {
         $cache = apcu_cache_info('user');
         $key = 'key';
     } elseif (function_exists('apc_cache_info')) {
         $cache = apc_cache_info('user');
         $key = 'info';
     }
     if ($cache && $key) {
         foreach ($cache['cache_list'] as $entry) {
             $keys[] = $entry[$key];
         }
     }
     return $keys;
 }
コード例 #7
0
ファイル: CacheApc.php プロジェクト: M03G/PrestaShop
 /**
  * Delete one or several data from cache (* joker can be used, but avoid it !)
  * 	E.g.: delete('*'); delete('my_prefix_*'); delete('my_key_name');
  *
  * @param string $key Cache key
  * @return bool Whether the key was deleted
  */
 public function delete($key)
 {
     if ($key == '*') {
         $this->flush();
     } elseif (strpos($key, '*') === false) {
         $this->_delete($key);
     } else {
         $pattern = str_replace('\\*', '.*', preg_quote($key));
         $cache_info = $this->apcu ? apcu_cache_info('') : apc_cache_info('');
         foreach ($cache_info['cache_list'] as $entry) {
             if (isset($entry['key'])) {
                 $key = $entry['key'];
             } else {
                 $key = $entry['info'];
             }
             if (preg_match('#^' . $pattern . '$#', $key)) {
                 $this->_delete($key);
             }
         }
     }
     return true;
 }
コード例 #8
0
ファイル: apcu.php プロジェクト: N6REJ/joomla-cms
 /**
  * Garbage collect expired cache data
  *
  * @return  boolean
  *
  * @since   3.5
  */
 public function gc()
 {
     $allinfo = apcu_cache_info();
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         // The internal key name changed with APCu 4.0.7 from key to info
         $internalKey = isset($key['info']) ? $key['info'] : $key['key'];
         if (strpos($internalKey, $secret . '-cache-')) {
             apcu_fetch($internalKey);
         }
     }
     return true;
 }
コード例 #9
0
ファイル: apcu.php プロジェクト: WLR86/f3-admin
<?php

if (!function_exists('apcu_cache_info')) {
    ?>
    <p class="alert alert-danger">You do not have APCu installed</p>
    <?php 
    return;
}
/**
 * Fetch configuration and status information
 */
$info = apcu_cache_info();
//echo \Dsc\Debug::dump(array_keys($info));
$mem = apcu_sma_info();
/**
 * Turn bytes into a human readable format
 * @param $bytes
 */
function size_for_humans($bytes)
{
    if ($bytes > 1048576) {
        return sprintf("%.2f&nbsp;MB", $bytes / 1048576);
    } elseif ($bytes > 1024) {
        return sprintf("%.2f&nbsp;kB", $bytes / 1024);
    } else {
        return sprintf("%d&nbsp;bytes", $bytes);
    }
}
?>
            
            <div class="panel panel-default">
コード例 #10
0
ファイル: stat.php プロジェクト: mkalam-alami/ludumdare
if (!$show_specific) {
    $response['name'] = gethostname();
    $response['php_version'] = PHP_VERSION;
}
// OpCache //
if (!$show_specific) {
    if (function_exists('opcache_is_script_cached')) {
        // Technically, this is checking if this file is cached //
        $response['opcache_enabled'] = opcache_is_script_cached(__FILE__);
    }
}
// APCu //
if (defined('CMW_USING_APCU') && !$show_specific) {
    $response['apcu_api_version'] = phpversion('apcu');
    if (function_exists('apcu_cache_info')) {
        $response['apcu_uptime'] = time() - intval(apcu_cache_info(true)['start_time']);
    }
}
// Database //
if (defined('CMW_USING_DB') && $show_db) {
    $response['db_api_version'] = phpversion('mysqli');
    if ($is_admin) {
        require_once __DIR__ . "/../../db.php";
        $db_data = db_QueryFetchPair("show VARIABLES like \"%version%\"");
        $response['db_version'] = $db_data['version'];
        $db_data = db_QueryFetchPair("show global status where Variable_Name = 'Uptime';");
        $response['db_uptime'] = time_offset() + intval($db_data['Uptime']);
    }
}
// Redis //
if (defined('CMW_USING_REDIS') && $show_redis) {
コード例 #11
0
ファイル: ApcEngine.php プロジェクト: mgoo/MovieServer
 /**
  * Delete all keys from the cache. This will clear every cache config using APC.
  *
  * @param bool $check If true, nothing will be cleared, as entries are removed
  *    from APC as they expired. This flag is really only used by FileEngine.
  * @return bool True Returns true.
  */
 public function clear($check)
 {
     if ($check) {
         return true;
     }
     $func = $this->_apcExtension . '_delete';
     if (class_exists('APCIterator', false)) {
         $iterator = new APCIterator('user', '/^' . preg_quote($this->settings['prefix'], '/') . '/', APC_ITER_NONE);
         $func($iterator);
         return true;
     }
     $cache = $this->_apcExtension === 'apc' ? apc_cache_info('user') : apcu_cache_info();
     foreach ($cache['cache_list'] as $key) {
         if (strpos($key['info'], $this->settings['prefix']) === 0) {
             $func($key['info']);
         }
     }
     return true;
 }
コード例 #12
0
ファイル: ApcuCache.php プロジェクト: naldz/cyberden
 /**
  * {@inheritdoc}
  */
 protected function doGetStats()
 {
     $info = apcu_cache_info(true);
     $sma = apcu_sma_info();
     return array(Cache::STATS_HITS => $info['num_hits'], Cache::STATS_MISSES => $info['num_misses'], Cache::STATS_UPTIME => $info['start_time'], Cache::STATS_MEMORY_USAGE => $info['mem_size'], Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem']);
 }
コード例 #13
0
ファイル: cache.php プロジェクト: xiaoniainiu/php-yaf-yk
 public function info($type = 'user', $limit = false)
 {
     return apcu_cache_info($type, $limit);
 }
コード例 #14
0
ファイル: UserController.php プロジェクト: xzungshao/lar5-one
 public function apcu_get()
 {
     $res = apcu_fetch($this->key);
     //var_dump($res);
     return apcu_cache_info();
 }
コード例 #15
0
ファイル: index.php プロジェクト: ovr/apc-dashboard
    }
    /**
     * @param string $type
     * @param bool $limited
     * @return array|bool Array of cached data (and meta-data) or FALSE on failure.
     */
    function apcu_cache_info($type = '', $limited = false)
    {
        return apc_cache_info($type, $limited);
    }
    class APCUIterator extends APCIterator
    {
    }
}
$smaInfo = apcu_sma_info();
$cacheInfo = apcu_cache_info();
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <table>
        <tr>
            <td colspan="2">
               <h2>Cache Information</h2>
            </td>
        </tr>
コード例 #16
0
ファイル: apc.php プロジェクト: bitweaver/kernel
            $AUTHENTICATED = 1;
        }
    }
}
// clear cache
if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) {
    apcu_clear_cache();
}
if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) {
    apcu_delete($MYREQUEST['DU']);
}
if (!function_exists('apcu_cache_info')) {
    echo "No cache info available.  APC does not appear to be running.";
    exit;
}
$cache = apcu_cache_info();
$mem = apcu_sma_info();
// don't cache this page
//
header("Cache-Control: no-store, no-cache, must-revalidate");
// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// HTTP/1.0
function duration($ts)
{
    global $time;
    $years = (int) (($time - $ts) / (7 * 86400) / 52.177457);
    $rem = (int) ($time - $ts - $years * 52.177457 * 7 * 86400);
    $weeks = (int) ($rem / (7 * 86400));
    $days = (int) ($rem / 86400) - $weeks * 7;
コード例 #17
0
ファイル: ApcEngine.php プロジェクト: rlugojr/cakephp
 /**
  * Delete all keys from the cache. This will clear every cache config using APC.
  *
  * @param bool $check If true, nothing will be cleared, as entries are removed
  *    from APC as they expired. This flag is really only used by FileEngine.
  * @return bool True Returns true.
  */
 public function clear($check)
 {
     if ($check) {
         return true;
     }
     if (class_exists('APCUIterator', false)) {
         $iterator = new APCUIterator('/^' . preg_quote($this->_config['prefix'], '/') . '/', APC_ITER_NONE);
         apcu_delete($iterator);
         return true;
     }
     $cache = apcu_cache_info();
     foreach ($cache['cache_list'] as $key) {
         if (strpos($key['info'], $this->_config['prefix']) === 0) {
             apcu_delete($key['info']);
         }
     }
     return true;
 }
コード例 #18
0
ファイル: uptime.php プロジェクト: LastResortGames/ludumdare
<?php

/* Uptime Check */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
require_once __DIR__ . "/../config.php";
require_once __DIR__ . "/../api.php";
// REMEMBER: The CloudFlare IPs are not whitelisted //
if (!core_OnWhitelist($_SERVER['REMOTE_ADDR'], CMW_ACCESS_DATA)) {
    json_EmitError(401);
}
$response = json_NewResponse();
if (defined('CMW_USING_APCU')) {
    $response['apcu'] = ["uptime" => time() - intval(apcu_cache_info("user")['start_time'])];
}
if (defined('CMW_USING_REDIS')) {
    $redis = new Redis();
    $redis->connect(CMW_REDIS_HOST);
    $response['redis'] = ["uptime" => intval($redis->info('default')['uptime_in_seconds'])];
    $redis->close();
}
if (defined('CMW_USING_DB')) {
    require_once __DIR__ . "/../db.php";
    db_connect();
    $db_data = db_FetchArrayPair("show global status where Variable_Name = 'Uptime';");
    $response['db'] = ["uptime" => intval($db_data['Uptime'])];
    db_close();
}
if (defined('CMW_USING_MEMCACHED')) {
    $m = new Memcached();
コード例 #19
0
ファイル: Apc.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Get all cached data
  *
  * @return  array
  */
 public function all()
 {
     $allinfo = $this->apcu ? apcu_cache_info() : apc_cache_info('user');
     $keys = $allinfo['cache_list'];
     $hash = $this->options['hash'];
     $data = array();
     foreach ($keys as $key) {
         $name = $key['info'];
         $namearr = explode('-', $name);
         if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache') {
             $group = $namearr[2];
             if (!isset($data[$group])) {
                 $item = new Auditor($group);
             } else {
                 $item = $data[$group];
             }
             $item->tally($key['mem_size'] / 1024);
             $data[$group] = $item;
         }
     }
     return $data;
 }
コード例 #20
0
 /**
  * Return apcu cache info
  * @param \Slim\Http\Request $req http request
  * @param \Slim\Http\Response $res http response
  */
 public function status(Request $req, Response $res)
 {
     return $res->withStatus(200)->withHeader('Content-type', 'application/json')->write(json_encode(apcu_cache_info(), JSON_PRETTY_PRINT));
 }
コード例 #21
0
ファイル: apcu.php プロジェクト: jwest00724/joomla-cms
 /**
  * Force garbage collect expired cache data as items are removed only on fetch!
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   3.5
  */
 public function gc()
 {
     $allinfo = apcu_cache_info();
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (strpos($key['info'], $secret . '-cache-')) {
             apcu_fetch($key['info']);
         }
     }
     return true;
 }
コード例 #22
0
ファイル: polyfill.php プロジェクト: lavoiesl/apc-polyfill
 function apc_cache_info($cache_type = "", $limited = false)
 {
     return apcu_cache_info($cache_type, $limited);
 }
コード例 #23
0
ファイル: cacheinfo.php プロジェクト: s4z/plumd
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 * @author     Kenny Freeman <*****@*****.**>
 * @copyright  2016 Kenny Freeman
 * @license    https://opensource.org/licenses/ISC
 */
// Ensure cache info functions exist
$opc_ci = function_exists('opcache_get_status');
// Apc can be apcu or apc
$apc_ci = function_exists('apc_cache_info');
$apcu_ci = function_exists('apcu_cache_info');
// Apc Shared Memory Allocation (sma)
$apc_sma_ci = function_exists('apc_sma_info');
// Get cache info
$oc_metrics = $opc_ci ? opcache_get_status(False) : array();
$apc_metrics = $apcu_ci ? apcu_cache_info(True) : array();
$sma_metrics = $apc_sma_ci ? apc_sma_info(True) : array();
// Apc Metrics if Apcu not available
if ($apc_ci && !$apcu_ci) {
    // older php install - can have (cache_type, limited) or (limited)
    $ref_apc = new ReflectionFunction('apc_cache_info');
    $nargs = count($ref_apc->getParameters());
    switch ($nargs) {
        case 1:
            $apc_metrics = apc_cache_info(True);
            break;
        case 2:
            // old cache that still has opcache in it..
            $apc_metrics = apc_cache_info("user", True);
            break;
        default:
コード例 #24
0
ファイル: ApcWrapper.php プロジェクト: jooorooo/cache
 /**
  * Remove all items from the cache.
  *
  * @return void
  */
 public function cacheList()
 {
     $list = $this->apcu ? apcu_cache_info() : apc_cache_info();
     return isset($list['cache_list']) ? $list['cache_list'] : [];
 }
コード例 #25
0
ファイル: apcu.php プロジェクト: siddht1/abantecart-src
 /**
  * Delete expired cache data
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   1.2.7
  */
 public function gc()
 {
     $cache_info = apcu_cache_info();
     $keys = $cache_info['cache_list'];
     foreach ($keys as $key) {
         // If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
         $internalKey = isset($key['info']) ? $key['info'] : $key['key'];
         if (strpos($internalKey, $this->secret . '-cache-')) {
             apcu_fetch($internalKey);
         }
     }
     return true;
 }
コード例 #26
0
ファイル: apcu.php プロジェクト: lyrasoft/lyrasoft.github.io
 /**
  * Garbage collect expired cache data
  *
  * @return  boolean
  *
  * @since   3.5
  */
 public function gc()
 {
     $allinfo = apcu_cache_info();
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (isset($key['info'])) {
             // The internal key name changed with APCu 4.0.7 from key to info
             $internalKey = $key['info'];
         } elseif (isset($key['entry_name'])) {
             // Some APCu modules changed the internal key name from key to entry_name
             $internalKey = $key['entry_name'];
         } else {
             // A fall back for the old internal key name
             $internalKey = $key['key'];
         }
         if (strpos($internalKey, $secret . '-cache-')) {
             apcu_fetch($internalKey);
         }
     }
     return true;
 }
コード例 #27
0
ファイル: polyfill.php プロジェクト: rezzza/apc-polyfill
 function apc_cache_info($cache_type, $limited = false)
 {
     apcu_cache_info($cache_type, $limited);
 }