public function initialize($options = array()) { if (!isset($options['cache_dir']) && isset($options['prefix'])) { $options['cache_dir'] = dmOs::join(sfConfig::get("sf_cache_dir"), $options['prefix']); } return parent::initialize($options); }
/** * Writes a cache file. * * @param string An absolute filesystem path to a configuration file * @param string An absolute filesystem path to the cache file that will be written * @param string Data to be written to the cache file * * @throws sfCacheException If the cache file cannot be written */ protected function writeCacheFile($config, $cache, &$data) { $fileCache = new sfFileCache(dirname($cache)); $fileCache->initialize(array('lifeTime' => 86400 * 365 * 10, 'automaticCleaningFactor' => 0)); $fileCache->setWriteControl(true); $fileCache->setSuffix(''); if (!$fileCache->set(basename($cache), '', $data)) { $fileCache->remove(basename($cache), ''); throw new sfConfigurationException(sprintf('Unable to write config cache for "%s".', $config)); } }
public function initialize($options = array()) { $options = array_merge($options, array('cache_dir' => self::getCacheDir())); parent::initialize($options); }
/* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; require_once dirname(__FILE__) . '/sfCacheDriverTests.class.php'; $t = new lime_test(36, new lime_output_color()); // setup sfConfig::set('sf_logging_enabled', false); $temp = tempnam('/tmp/cachedir', 'tmp'); unlink($temp); mkdir($temp); $cache = new sfFileCache($temp); sfCacheDriverTests::launch($t, $cache); // teardown sfToolkit::clearDirectory($temp); rmdir($temp); $temp = tempnam('/tmp/cachedir', 'tmp'); unlink($temp); mkdir($temp); // Create a file cache using initialize() method $cache = new sfFileCache(); $cache->initialize(array('cacheDir' => $temp)); sfCacheDriverTests::launch($t, $cache); // teardown sfToolkit::clearDirectory($temp); rmdir($temp);