public function __call($method, array $args) { if ($method != 'loaded' and $this->loaded()) { $exploded = explode('_', strtolower($method)); if (count($exploded) == 3 and $exploded[2] == 'count') { $type = $action = NULL; if (in_array($exploded[0], array('increment', 'decrement'))) { $action = $exploded[0]; } if (in_array($exploded[1], array('views', 'comments'))) { $type = $exploded[1]; } if ($type !== NULL and $action !== NULL) { $key = array('count', $type, $this->id, date('Ymd')); $key = implode('_', $key); $default = parent::__get($type . '_count'); $result = Cache::instance('memcache')->{$action}($key, 1, $default); return $result; } } } return parent::__call($method, $args); }