Example #1
0
	public function __construct() {
		$this->extension['redis'] = extension_loaded('redis');
		$this->extension['memcache'] = extension_loaded('memcache');
		$this->extension['apc'] = function_exists('apc_cache_info') && @apc_cache_info();
		$this->extension['xcache'] = function_exists('xcache_get');
		$this->extension['eaccelerator'] = function_exists('eaccelerator_get');
		$this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo();
	}
Example #2
0
 function memory()
 {
     $this->extension['redis'] = extension_loaded('redis');
     $this->extension['memcache'] = extension_loaded('memcache');
     $this->extension['apc'] = function_exists('apc_cache_info') && apc_cache_info();
     $this->extension['xcache'] = function_exists('xcache_get');
     $this->extension['eaccelerator'] = function_exists('eaccelerator_get');
     $this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo();
     $this->init();
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function doGetStats()
 {
     $info = wincache_ucache_info();
     $meminfo = wincache_ucache_meminfo();
     return array(Cache::STATS_HITS => $info['total_hit_count'], Cache::STATS_MISSES => $info['total_miss_count'], Cache::STATS_UPTIME => $info['total_cache_uptime'], Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], Cache::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free']);
 }
 /**
  * @see wincache_ucache_meminfo();
  */
 public function memInfo()
 {
     return wincache_ucache_meminfo();
 }
Example #5
0
 /**
  * Return the filling percentage of the backend storage
  *
  * @throws IfwPsn_Vendor_Zend_Cache_Exception
  * @return int integer between 0 and 100
  */
 public function getFillingPercentage()
 {
     $mem = wincache_ucache_meminfo();
     $memSize = $mem['memory_total'];
     $memUsed = $memSize - $mem['memory_free'];
     if ($memSize == 0) {
         IfwPsn_Vendor_Zend_Cache::throwException('can\'t get WinCache memory size');
     }
     if ($memUsed > $memSize) {
         return 100;
     }
     return (int) (100.0 * ($memUsed / $memSize));
 }
 /**
  * @override \local_telemetry\request_state
  */
 public function get_records()
 {
     $record = new stdClass();
     $filecachefileinfo = wincache_fcache_fileinfo(true);
     if ($filecachefileinfo) {
         $record->f_f_uptime = $filecachefileinfo['total_cache_uptime'];
         $record->f_f_items = $filecachefileinfo['total_file_count'];
         $record->f_f_hits = $filecachefileinfo['total_hit_count'];
         $record->f_f_misses = $filecachefileinfo['total_miss_count'];
     }
     $filecachememinfo = wincache_fcache_meminfo();
     if ($filecachememinfo) {
         $record->f_m_total = $filecachememinfo['memory_total'];
         $record->f_m_free = $filecachememinfo['memory_free'];
         $record->f_m_used_blocks = $filecachememinfo['num_used_blks'];
         $record->f_m_free_blocks = $filecachememinfo['num_free_blks'];
         $record->f_m_overhead = $filecachememinfo['memory_overhead'];
     }
     $opcodecachefileinfo = wincache_ocache_fileinfo(true);
     if ($opcodecachefileinfo) {
         $record->o_f_uptime = $opcodecachefileinfo['total_cache_uptime'];
         $record->o_f_items = $opcodecachefileinfo['total_file_count'];
         $record->o_f_hits = $opcodecachefileinfo['total_hit_count'];
         $record->o_f_misses = $opcodecachefileinfo['total_miss_count'];
         $record->o_f_islocal = $opcodecachefileinfo['is_local_cache'];
     }
     $opcodecachememinfo = wincache_ocache_meminfo();
     if ($opcodecachememinfo) {
         $record->o_m_total = $opcodecachememinfo['memory_total'];
         $record->o_m_free = $opcodecachememinfo['memory_free'];
         $record->o_m_used_blocks = $opcodecachememinfo['num_used_blks'];
         $record->o_m_free_blocks = $opcodecachememinfo['num_free_blks'];
         $record->o_m_overhead = $opcodecachememinfo['memory_overhead'];
     }
     $resolvedpathcachefileinfo = wincache_rplist_fileinfo(true);
     if ($resolvedpathcachefileinfo) {
         $record->rp_f_files = $resolvedpathcachefileinfo['total_file_count'];
     }
     $resolvedpathcachememinfo = wincache_rplist_meminfo();
     if ($resolvedpathcachememinfo) {
         $record->rp_m_total = $resolvedpathcachememinfo['memory_total'];
         $record->rp_m_free = $resolvedpathcachememinfo['memory_free'];
         $record->rp_m_used_blocks = $resolvedpathcachememinfo['num_used_blks'];
         $record->rp_m_free_blocks = $resolvedpathcachememinfo['num_free_blks'];
         $record->rp_m_overhead = $resolvedpathcachememinfo['memory_overhead'];
     }
     $sessioncacheinfo = wincache_scache_info(true);
     if ($sessioncacheinfo) {
         $record->s_i_uptime = $sessioncacheinfo['total_cache_uptime'];
         $record->s_i_items = $sessioncacheinfo['total_item_count'];
         $record->s_i_islocal = $sessioncacheinfo['is_local_cache'];
         $record->s_i_hits = $sessioncacheinfo['total_hit_count'];
         $record->s_i_misses = $sessioncacheinfo['total_miss_count'];
     }
     $sessioncachememinfo = wincache_scache_meminfo();
     if ($sessioncachememinfo) {
         $record->s_m_total = $sessioncachememinfo['memory_total'];
         $record->s_m_free = $sessioncachememinfo['memory_free'];
         $record->s_m_used_blocks = $sessioncachememinfo['num_used_blks'];
         $record->s_m_free_blocks = $sessioncachememinfo['num_free_blks'];
         $record->s_m_overhead = $sessioncachememinfo['memory_overhead'];
     }
     $usercacheinfo = wincache_ucache_info(true);
     if ($usercacheinfo) {
         $record->u_i_uptime = $usercacheinfo['total_cache_uptime'];
         $record->u_i_items = $usercacheinfo['total_item_count'];
         $record->u_i_islocal = $usercacheinfo['is_local_cache'];
         $record->u_i_hits = $usercacheinfo['total_hit_count'];
         $record->u_i_misses = $usercacheinfo['total_miss_count'];
     }
     $usercachememinfo = wincache_ucache_meminfo();
     if ($usercachememinfo) {
         $record->u_m_total = $usercachememinfo['memory_total'];
         $record->u_m_free = $usercachememinfo['memory_free'];
         $record->u_m_used_blocks = $usercachememinfo['num_used_blks'];
         $record->u_m_free_blocks = $usercachememinfo['num_free_blks'];
         $record->u_m_overhead = $usercachememinfo['memory_overhead'];
     }
     return array($record);
 }
 /**
  * Get available space in bytes
  *
  * @return int|float
  */
 public function getAvailableSpace()
 {
     $mem = wincache_ucache_meminfo();
     return $mem['memory_free'];
 }
Example #8
0
 /**
  * Internal method to get storage capacity.
  *
  * @param  array $normalizedOptions
  * @return array|boolean Capacity as array or false on failure
  * @throws Exception
  */
 protected function internalGetCapacity(array &$normalizedOptions)
 {
     $mem = wincache_ucache_meminfo();
     return array('free' => $mem['memory_free'], 'total' => $mem['memory_total']);
 }
Example #9
0
function init_cache_info($cache_data = SUMMARY_DATA)
{
    global $ocache_mem_info, $ocache_file_info, $ocache_summary_info, $fcache_mem_info, $fcache_file_info, $fcache_summary_info, $rpcache_mem_info, $rpcache_file_info, $ucache_mem_info, $ucache_info, $scache_mem_info, $scache_info, $user_cache_available, $session_cache_available;
    if ($cache_data == SUMMARY_DATA || $cache_data == OCACHE_DATA) {
        $ocache_mem_info = wincache_ocache_meminfo();
        $ocache_file_info = wincache_ocache_fileinfo();
        $ocache_summary_info = get_ocache_summary($ocache_file_info['file_entries']);
    }
    if ($cache_data == SUMMARY_DATA || $cache_data == FCACHE_DATA) {
        $fcache_mem_info = wincache_fcache_meminfo();
        $fcache_file_info = wincache_fcache_fileinfo();
        $fcache_summary_info = get_fcache_summary($fcache_file_info['file_entries']);
    }
    if ($cache_data == SUMMARY_DATA || $cache_data == RCACHE_DATA) {
        $rpcache_mem_info = wincache_rplist_meminfo();
        $rpcache_file_info = wincache_rplist_fileinfo();
    }
    if ($user_cache_available && ($cache_data == SUMMARY_DATA || $cache_data == UCACHE_DATA)) {
        $ucache_mem_info = wincache_ucache_meminfo();
        $ucache_info = wincache_ucache_info();
    }
    if ($session_cache_available && ($cache_data == SUMMARY_DATA || $cache_data == SCACHE_DATA)) {
        $scache_mem_info = wincache_scache_meminfo();
        $scache_info = wincache_scache_info();
    }
}
Example #10
0
 /**
  * {@inheritDoc}
  */
 public function getStats()
 {
     $info = wincache_ucache_info(true);
     $meminfo = wincache_ucache_meminfo();
     return array(CacheInterface::STATS_SIZE => $info['total_item_count'], CacheInterface::STATS_HITS => $info['total_hit_count'], CacheInterface::STATS_MISSES => $info['total_miss_count'], CacheInterface::STATS_UPTIME => $info['total_cache_uptime'], CacheInterface::STATS_MEMORY_USAGE => $meminfo['memory_total'], CacheInterface::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free']);
 }
Example #11
0
 /**
  * @return driverStatistic
  */
 public function getStats()
 {
     $memInfo = wincache_ucache_meminfo();
     $info = wincache_ucache_info();
     $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
     return (new driverStatistic())->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))->setSize($memInfo['memory_free'] - $memInfo['memory_total'])->setData(implode(', ', array_keys($this->itemInstances)))->setRawData($memInfo);
 }
Example #12
0
 /**
  * Get storage capacity.
  *
  * @param  array $options
  * @return array|boolean Capacity as array or false on failure
  *
  * @triggers getCapacity.pre(PreEvent)
  * @triggers getCapacity.post(PostEvent)
  * @triggers getCapacity.exception(ExceptionEvent)
  */
 public function getCapacity(array $options = array())
 {
     $args = new ArrayObject(array('options' => &$options));
     try {
         $eventRs = $this->triggerPre(__FUNCTION__, $args);
         if ($eventRs->stopped()) {
             return $eventRs->last();
         }
         $mem = wincache_ucache_meminfo();
         $result = array('free' => $mem['memory_free'], 'total' => $mem['memory_total']);
         return $this->triggerPost(__FUNCTION__, $args, $result);
     } catch (\Exception $e) {
         return $this->triggerException(__FUNCTION__, $args, $e);
     }
 }
Example #13
0
File: Wincache.php Project: ksst/kf
 /**
  * Returns an array with stats and usage informations for display.
  *
  * @return array
  */
 public function stats()
 {
     $info = wincache_ucache_info();
     $meminfo = wincache_ucache_meminfo();
     return [CacheInterface::STATS_HITS => $info['total_hit_count'], CacheInterface::STATS_MISSES => $info['total_miss_count'], CacheInterface::STATS_UPTIME => $info['total_cache_uptime'], CacheInterface::STATS_MEMORY_USAGE => $meminfo['memory_total'], CacheInterface::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free']];
 }
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function stats()
 {
     $stats = wincache_ucache_info();
     $memory = wincache_ucache_meminfo();
     return [static::HITS => $stats['total_hit_count'], static::MISSES => $stats['total_miss_count'], static::UPTIME => $stats['total_cache_uptime'], static::MEMORY_USAGE => $memory['memory_total'], static::MEMORY_AVAILABLE => $memory['memory_free']];
 }