piler/webui/model/stat/counter.php

43 lines
1.1 KiB
PHP
Raw 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']; }
2014-05-05 16:00:33 +02:00
if(isset($counter[MEMCACHED_PREFIX . 'stored_size'])) { $ssize = $counter[MEMCACHED_PREFIX . 'stored_size']; }
2012-02-10 14:35:07 +01:00
unset($counter[MEMCACHED_PREFIX . 'size']);
2014-05-05 16:00:33 +02:00
unset($counter[MEMCACHED_PREFIX . 'stored_size']);
2012-02-10 14:35:07 +01:00
2014-05-05 16:00:33 +02:00
return array ($asize, $ssize, $counter);
2012-02-10 14:35:07 +01:00
}
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'];
2014-05-05 16:00:33 +02:00
$ssize = $query->row['stored_size'];
2013-02-16 12:51:43 +01:00
2012-02-10 14:35:07 +01:00
unset($query->row['size']);
2014-05-05 16:00:33 +02:00
unset($query->row['stored_size']);
2012-02-10 14:35:07 +01:00
2012-02-08 23:14:28 +01:00
$counter = $query->row;
}
2014-05-05 16:00:33 +02:00
return array ($asize, $ssize, $counter);
2012-02-08 23:14:28 +01:00
}
}
?>