diff -r 000000000000 -r 7f95f8617b0b vendor/doctrine-common/lib/Doctrine/Common/Cache/XcacheCache.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/doctrine-common/lib/Doctrine/Common/Cache/XcacheCache.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,105 @@ +. + */ + +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.'); + } + } +} \ No newline at end of file