piler/webui/model/stat/counter.php

39 lines
849 B
PHP
Raw Permalink Normal View History

2012-02-08 23:14:28 +01:00
<?php
class ModelStatCounter extends Model {
2012-06-22 15:22:02 +02:00
public function get_counters(){
2012-02-08 23:14:28 +01:00
$counter = array();
2012-02-10 14:35:07 +01:00
$asize = 0;
2012-02-08 23:14:28 +01:00
if(MEMCACHED_ENABLED) {
$memcache = Registry::get('memcache');
$counter = $memcache->get(Registry::get('counters'));
2012-02-10 14:35:07 +01:00
if(isset($counter[MEMCACHED_PREFIX . 'counters_last_update'])) {
2013-02-16 12:51:43 +01:00
if(isset($counter[MEMCACHED_PREFIX . 'size'])) { $asize = $counter[MEMCACHED_PREFIX . 'size']; }
2012-02-10 14:35:07 +01:00
unset($counter[MEMCACHED_PREFIX . 'size']);
return array ($asize, $counter);
}
2012-02-08 23:14:28 +01:00
}
$query = $this->db->query("SELECT * FROM " . TABLE_COUNTER);
if($query->num_rows == 1) {
2013-02-16 12:51:43 +01:00
$asize = $query->row['size'];
2012-02-10 14:35:07 +01:00
unset($query->row['size']);
2012-02-08 23:14:28 +01:00
$counter = $query->row;
}
2012-02-10 14:35:07 +01:00
return array ($asize, $counter);
2012-02-08 23:14:28 +01:00
}
}
?>