. */ namespace Doctrine\Common\Cache; /** * Xcache cache driver. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @version $Revision: 3938 $ * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel * @author David Abdemoulaie */ class XcacheCache extends AbstractCache { /** * {@inheritdoc} */ public function getIds() { $this->_checkAuth(); $keys = array(); for ($i = 0, $count = xcache_count(XC_TYPE_VAR); $i < $count; $i++) { $entries = xcache_list(XC_TYPE_VAR, $i); if (is_array($entries['cache_list'])) { foreach ($entries['cache_list'] as $entry) { $keys[] = $entry['name']; } } } return $keys; } /** * {@inheritdoc} */ protected function _doFetch($id) { return $this->_doContains($id) ? unserialize(xcache_get($id)) : false; } /** * {@inheritdoc} */ protected function _doContains($id) { return xcache_isset($id); } /** * {@inheritdoc} */ protected function _doSave($id, $data, $lifeTime = 0) { return xcache_set($id, serialize($data), (int) $lifeTime); } /** * {@inheritdoc} */ protected function _doDelete($id) { return xcache_unset($id); } /** * Checks that xcache.admin.enable_auth is Off * * @throws \BadMethodCallException When xcache.admin.enable_auth is On * @return void */ protected function _checkAuth() { if (ini_get('xcache.admin.enable_auth')) { throw new \BadMethodCallException('To use all features of \Doctrine\Common\Cache\XcacheCache, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'); } } }