. */ namespace Doctrine\Common\Cache; /** * Array cache driver. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel * @author David Abdemoulaie */ class ArrayCache extends CacheProvider { /** * @var array $data */ private $data = array(); /** * {@inheritdoc} */ protected function doFetch($id) { return (isset($this->data[$id])) ? $this->data[$id] : false; } /** * {@inheritdoc} */ protected function doContains($id) { return isset($this->data[$id]); } /** * {@inheritdoc} */ protected function doSave($id, $data, $lifeTime = 0) { $this->data[$id] = $data; return true; } /** * {@inheritdoc} */ protected function doDelete($id) { unset($this->data[$id]); return true; } /** * {@inheritdoc} */ protected function doFlush() { $this->data = array(); return true; } /** * {@inheritdoc} */ protected function doGetStats() { return null; } }