public function testCacheDefault() { Cache::set_cache_lifetime('default', 1200); $default = Cache::get_cache_lifetime('default'); $this->assertEquals(1200, $default['lifetime']); $cache = Cache::factory('somethingnew'); $this->assertEquals(1200, $cache->getOption('lifetime')); }
/** * Get the cache object to use when storing / retrieving partial cache blocks. * * @return Zend_Cache_Core */ public function getPartialCacheStore() { return $this->partialCacheStore ? $this->partialCacheStore : Cache::factory('cacheblock'); }
public function tearDown() { $cache = Cache::factory('GDBackend_Manipulations'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); parent::tearDown(); }
/** * Tests the integrity of the manipulation cache when an error occurs */ public function testCacheIntegrity() { $fullPath = realpath(dirname(__FILE__) . '/gdtest/nonimagedata.jpg'); // Load invalid file $gd = new GDBackend(); $gd->loadFrom($fullPath); // Cache should refer to this file $cache = Cache::factory('GDBackend_Manipulations'); $key = sha1(implode('|', array($fullPath, filemtime($fullPath)))); $data = $cache->load($key); $this->assertEquals('1', $data); }
/** * Return the version number of this application. * Uses the number in <mymodule>/silverstripe_version * (automatically replaced by build scripts). * If silverstripe_version is empty, * then attempts to get it from composer.lock * * @return string */ public function CMSVersion() { $versions = array(); $modules = array('silverstripe/framework' => array('title' => 'Framework', 'versionFile' => FRAMEWORK_PATH . '/silverstripe_version')); if (defined('CMS_PATH')) { $modules['silverstripe/cms'] = array('title' => 'CMS', 'versionFile' => CMS_PATH . '/silverstripe_version'); } // Tries to obtain version number from composer.lock if it exists $composerLockPath = BASE_PATH . '/composer.lock'; if (file_exists($composerLockPath)) { $cache = Cache::factory('LeftAndMain_CMSVersion'); $cacheKey = filemtime($composerLockPath); $versions = $cache->load($cacheKey); if ($versions) { $versions = json_decode($versions, true); } else { $versions = array(); } if (!$versions && ($jsonData = file_get_contents($composerLockPath))) { $lockData = json_decode($jsonData); if ($lockData && isset($lockData->packages)) { foreach ($lockData->packages as $package) { if (array_key_exists($package->name, $modules) && isset($package->version)) { $versions[$package->name] = $package->version; } } $cache->save(json_encode($versions), $cacheKey); } } } // Fall back to static version file foreach ($modules as $moduleName => $moduleSpec) { if (!isset($versions[$moduleName])) { if ($staticVersion = file_get_contents($moduleSpec['versionFile'])) { $versions[$moduleName] = $staticVersion; } else { $versions[$moduleName] = _t('LeftAndMain.VersionUnknown', 'Unknown'); } } } $out = array(); foreach ($modules as $moduleName => $moduleSpec) { $out[] = $modules[$moduleName]['title'] . ': ' . $versions[$moduleName]; } return implode(', ', $out); }
public static function flush() { // Clear factory $cache = Cache::factory('GDBackend_Manipulations'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); }
protected function _reset($cacheOn = true) { $this->data = new SSViewerCacheBlockTest_Model(); Cache::factory('cacheblock')->clean(); Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1); }
/** * Provides a hook for mock unit tests despite no DI * @return Zend_Cache_Core */ protected function getCache() { return Cache::factory('SS_Configuration', 'Core', array('automatic_serialization' => true, 'lifetime' => null)); }
/** * Return an instance of the cache used for i18n data. * * @skipUpgrade * @return Zend_Cache_Core */ public static function get_cache() { return Cache::factory('i18n', 'Output', array('lifetime' => null, 'automatic_serialization' => true)); }
use SilverStripe\Core\Cache; use SilverStripe\Dev\Deprecation; use SilverStripe\View\Parsers\ShortcodeParser; /** * Framework configuration file * * Here you can make different settings for the Framework module (the core * module). * * For example you can register the authentication methods you wish to use * on your site, e.g. to register the OpenID authentication method type * * <code> * Authenticator::register_authenticator('OpenIDAuthenticator'); * </code> */ ShortcodeParser::get('default')->register('file_link', array('SilverStripe\\Assets\\File', 'handle_shortcode'))->register('embed', array('SilverStripe\\Forms\\HtmlEditor\\EmbedShortcodeProvider', 'handle_shortcode'))->register('image', array('SilverStripe\\Assets\\Image', 'handle_shortcode')); // Shortcode parser which only regenerates shortcodes ShortcodeParser::get('regenerator')->register('image', array('SilverStripe\\Assets\\Image', 'regenerate_shortcode')); // @todo // ->register('dbfile_link', array('DBFile', 'handle_shortcode')) // Zend_Cache temp directory setting $_ENV['TMPDIR'] = TEMP_FOLDER; // for *nix $_ENV['TMP'] = TEMP_FOLDER; // for Windows Cache::set_cache_lifetime('GDBackend_Manipulations', null, 100); // If you don't want to see deprecation errors for the new APIs, change this to 3.2.0-dev. Deprecation::notification_version('3.2.0'); // TODO Remove once new ManifestBuilder with submodule support is in place require_once 'admin/_config.php';