public function index($arguments) { $news = new news(ConnectionFactory::get('mongo')); $articles = new articles(ConnectionFactory::get('mongo')); $notices = new notices(ConnectionFactory::get('redis')); $irc = new irc(ConnectionFactory::get('redis')); $quotes = new quotes(ConnectionFactory::get('mongo')); $forums = new forums(ConnectionFactory::get('redis')); // Set all site-wide notices. foreach ($notices->getAll() as $notice) { Error::set($notice, true); } // Fetch the easy data. $this->view['news'] = $news->getNewPosts(); $this->view['shortNews'] = $news->getNewPosts(true); $this->view['newArticles'] = $articles->getNewPosts('new', 1, 5); $this->view['ircOnline'] = $irc->getOnline(); $this->view['randomQuote'] = $quotes->getRandom(); $this->view['fPosts'] = $forums->getNew(); // Get online users. $apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/'); $this->view['onlineUsers'] = array(); while ($apc->valid()) { $current = $apc->current(); array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5)); $apc->next(); } // Set title. Layout::set('title', 'Home'); }
public static function ApcPurge($func, $id) { $apc = new APCIterator('user', '/' . Cache::PREFIX . 'data_' . get_called_class() . '_' . $func . '-' . $id . '.*/'); while ($apc->valid()) { $current = $apc->current(); apc_delete($current['key']); $apc->next(); } }
/** * Move forward to next element * * @return void */ public function next() { $this->baseIterator->next(); }
<?php error_reporting(E_ALL & ~E_USER_NOTICE & ~E_NOTICE); echo "== No Search ==\n"; $it = new APCIterator('user'); apc_store('sample', 'x'); apc_store('another_sample', 'x'); foreach ($it as $key => $val) { // skip to end } var_dump($it->valid(), $it->key(), $it->current(), $it->next()); echo "== Search ==\n"; $it = new APCIterator('user', '/^b/'); // No elements, end? var_dump($it->valid(), $it->key(), $it->current(), $it->next());
/** * @param string $className * @depreciated */ public function clearClassCache($className = null) { $iterator = new \APCIterator('^user^'); while ($iterator->current()) { $tKey = $iterator->key(); if (mb_strpos($tKey, $className . '::') !== false) { apc_delete($tKey); } $iterator->next(); } }