public function testCacheDefault() { SS_Cache::set_cache_lifetime('default', 1200); $default = SS_Cache::get_cache_lifetime('default'); $this->assertEquals(1200, $default['lifetime']); $cache = SS_Cache::factory('somethingnew'); $this->assertEquals(1200, $cache->getOption('lifetime')); }
function testCacheLifetime() { SS_Cache::set_cache_lifetime('test', 0.5, 20); $cache = SS_Cache::factory('test'); $cache->save('Good', 'cachekey'); $this->assertEquals('Good', $cache->load('cachekey')); sleep(1); $this->assertFalse($cache->load('cachekey')); }
/** * Builds a cache of events if one doesn't exist, store the cache for 12 hours . The cache is cleared / reset * when a new event is published . * * @return json load of events to display */ public function getCachedData() { $cache = SS_Cache::factory('calendar'); SS_Cache::set_cache_lifetime('calendar', 60 * 60 * 12); if (!($result = unserialize($cache->load('events')))) { $result = $this->getData(); $cache->save(serialize($result), 'events'); } return $result; }
public static function parse($arguments, $content = null, $parser = null) { if (!array_key_exists('repo', $arguments) || empty($arguments['repo']) || strpos($arguments['repo'], '/') <= 0) { return '<p><i>GitHub repository undefined</i></p>'; } //Get Config $config = Config::inst()->forClass('GitHubShortCode'); $obj = new ViewableData(); //Add the Respository Setting $obj->Repository = $arguments['repo']; //Add Layout if (array_key_exists('layout', $arguments) && ($arguments['layout'] == 'inline' || $arguments['layout'] == 'stacked')) { $obj->Layout = $arguments['layout']; } else { $obj->Layout = 'inline'; } //Add the button config if (array_key_exists('show', $arguments) && ($arguments['show'] == 'both' || $arguments['show'] == 'stars' || $arguments['show'] == 'forks')) { $obj->ShowButton = $arguments['show']; } else { $obj->ShowButton = 'both'; } //Retrieve Stats SS_Cache::set_cache_lifetime('GitHubShortCode', $config->CacheTime); $cacheKey = md5('GitHubShortCode_' . $arguments['repo']); $cache = SS_Cache::factory('GitHubShortCode'); $cachedData = $cache->load($cacheKey); if ($cachedData == null) { $response = self::getFromAPI($arguments['repo'], $config); //Verify a 200, if not say the repo errored out and cache false if (empty($response) || $response === false || !property_exists($response, 'watchers') || !property_exists($response, 'forks')) { $cachedData = array('stargazers' => 'N/A', 'forks' => 'N/A'); } else { if ($config->UseShortHandNumbers == true) { $stargazers = self::shortHandNumber($response->stargazers_count); $forks = self::shortHandNumber($response->forks); } else { $stargazers = number_format($response->stargazers_count); $forks = number_format($response->forks); } $cachedData = array('stargazers' => $stargazers, 'forks' => $forks); } //Cache response to file system $cache->save(serialize($cachedData), $cacheKey); } else { $cachedData = unserialize($cachedData); } $obj->Stargazers = $cachedData['stargazers']; $obj->Forks = $cachedData['forks']; //Init ss viewer and render Requirements::css(GITHUBSHORTCODE_BASE . '/css/GitHubButtons.css'); $ssViewer = new SSViewer('GitHubButtons'); return $ssViewer->process($obj); }
public static function parse($arguments, $content = null, $parser = null) { if (!array_key_exists('package', $arguments) || empty($arguments['package']) || strpos($arguments['package'], '/') <= 0) { return '<p><i>Packagist package undefined</i></p>'; } //Get Config $config = Config::inst()->forClass('PackagistShortCode'); $obj = new ViewableData(); //Add the Respository Setting $obj->Package = $arguments['package']; //Add the button config if (array_key_exists('mode', $arguments) && ($arguments['mode'] == 'total' || $arguments['mode'] == 'monthly' || $arguments['mode'] == 'daily')) { $obj->DisplayMode = $arguments['mode']; } else { $obj->DisplayMode = 'total'; } //Retrieve Stats SS_Cache::set_cache_lifetime('PackagistShortCode', $config->CacheTime); $cacheKey = md5('packagistshortcode_' . $arguments['package']); $cache = SS_Cache::factory('PackagistShortCode'); $cachedData = $cache->load($cacheKey); if ($cachedData == null) { $response = self::getFromAPI($arguments['package']); //Verify a 200, if not say the repo errored out and cache false if (empty($response) || $response === false || !property_exists($response, 'package')) { $cachedData = array('total' => 'N/A', 'monthly' => 'N/A', 'daily' => 'N/A'); } else { if ($config->UseShortHandNumbers == true) { $totalDownloads = self::shortHandNumber($response->package->downloads->total); $monthlyDownloads = self::shortHandNumber($response->package->downloads->monthly); $dailyDownloads = self::shortHandNumber($response->package->downloads->daily); } else { $totalDownloads = number_format($response->package->downloads->total); $monthlyDownloads = number_format($response->package->downloads->monthly); $dailyDownloads = number_format($response->package->downloads->daily); } $cachedData = array('total' => $totalDownloads, 'monthly' => $monthlyDownloads, 'daily' => $dailyDownloads); } //Cache response to file system $cache->save(serialize($cachedData), $cacheKey); } else { $cachedData = unserialize($cachedData); } $obj->TotalDownloads = $cachedData['total']; $obj->MonthlyDownloads = $cachedData['monthly']; $obj->DailyDownloads = $cachedData['daily']; //Init ss viewer and render Requirements::css(PACKAGISTSHORTCODE_BASE . '/css/PackagistButton.css'); $ssViewer = new SSViewer('PackagistButton'); return $ssViewer->process($obj); }
/** * Sitetree getter, caches the whole sitetree per logged in user groups. * If a $partialChild is defined then the cache is bypassed and a partial sitetree is returned. * * @param Int $id Optional id used to define the parent to kick off from. * @param SiteTree $partialChild Optional partial child to get a site tree section from root. */ public function getStructure($id = 0, $partialChild = null) { if (!Member::currentUserID()) { throw new Exception('SiteTreeOrigamiApi::getStructure Not logged in'); } if ($partialChild) { $stack = array_reverse($partialChild->parentStack()); $result = $this->_structure($id, $stack); } else { // Check the cache. SS_Cache::set_cache_lifetime('SiteTree_Groups', 60 * 60); //one hour $cache = SS_Cache::factory('SiteTree_Groups', 'Output', array('automatic_serialization' => true)); // If there isn't a cached response call the API. if (!($result = $cache->load(SiteTreeOrigamiApi::get_cache_key()))) { $result = $this->_structure($id); $cache->save($result, SiteTreeOrigamiApi::get_cache_key()); } } return $result; }
public function IsProcessed() { if ($this->VimeoProcessingStatus == 'finished') { return true; } else { $cache = SS_Cache::factory('VimeoVideoFile_ApiRequest'); SS_Cache::set_cache_lifetime('VimeoVideoFile_ApiRequest', Config::inst()->get('VimeoVideoFile', 'api_request_time')); // set the waiting time if (!($result = $cache->load($this->ID))) { switch ($this->VimeoProcessingStatus) { case 'unprocessed': $this->process(); break; case 'updating': case 'processing': $this->appendLog($this->getLogFile(), 'IsProcessed - processing'); $lib = new \Vimeo\Vimeo(Config::inst()->get('VimeoVideoFile', 'client_id'), Config::inst()->get('VimeoVideoFile', 'client_secret'), Config::inst()->get('VimeoVideoFile', 'access_token')); // Send a request to vimeo for uploading the new video $video_data = $lib->request($this->VimeoURI); $this->extractUrls($video_data); // Set Title, Album and player preset $lib->request($this->VimeoURI, array('name' => $this->Name), 'PATCH'); if (Config::inst()->get('VimeoVideoFile', 'album_id')) { $res = $lib->request('/me/albums/' . Config::inst()->get('VimeoVideoFile', 'album_id') . $this->VimeoURI, array(), 'PUT'); $this->appendLog($this->getLogFile(), 'Updated Album', print_r($res, true)); } if (Config::inst()->get('VimeoVideoFile', 'preset_id')) { $res = $lib->request($this->VimeoURI . '/presets/' . Config::inst()->get('VimeoVideoFile', 'preset_id'), array(), 'PUT'); $this->appendLog($this->getLogFile(), 'Updated Player Preset', print_r($res, true)); } break; } $result = $this->VimeoProcessingStatus; $cache->save($result, $this->ID); } return $result == 'finished'; } }
<?php // recommended update time is 20 mins so play safe and go with 30. SS_Cache::set_cache_lifetime('any', 30 * 60);
<?php /** * SilverStripe Project */ global $project; $project = 'mysite'; /** * _ss_environment.php */ require_once "conf/ConfigureFromEnv.php"; /** * Email errors */ if (!Director::isDev()) { SS_Log::add_writer(new SS_LogEmailWriter(Email::getAdminEmail()), SS_Log::NOTICE, '<='); } /** * Keep the cache clean */ if (isset($_REQUEST['flush'])) { SS_Cache::set_cache_lifetime('any', -1, 100); } /** * Locale */ i18n::set_locale('en_US');
/** * This returns API responses saved to a SS_Cache file instead of the API response directly * as the Flickr API is often not reliable * * @param String $funcName Name of the function to call if cache expired or does not exist * @param array $args Arguments for the function * @return ArrayList<FlickrPhoto|FlickrPhotoset> */ public function getCachedCall($funcName, $args = array()) { $result = null; $argsCount = count($args); if ($argsCount < 1) { return $result; } // build up a unique cache name $cacheKey = array($funcName); foreach ($args as $arg) { $cacheKey[] = $arg; } // to hide api key and remove non alphanumeric characters $cacheKey = md5(implode('_', $cacheKey)); // setup cache $cache = SS_Cache::factory('FlickrService'); $cache->setOption('automatic_serialization', true); SS_Cache::set_cache_lifetime('FlickrService', $this->config()->flickr_hard_cache_expiry); // check if cached response exists or soft expiry has elapsed $metadata = $cache->getBackend()->getMetadatas('FlickrService' . $cacheKey); if (!($result = $cache->load($cacheKey)) || $this->softCacheExpired($metadata['mtime'])) { // try update the cache try { $result = call_user_func_array(array($this, $funcName), $args); // only update cache if result returned if ($result) { $cache->save($result, $cacheKey); } } catch (Exception $e) { SS_Log::log(sprintf("Couldn't retrieve Flickr photos using '%s': Message: %s", $funcName, $e->getMessage()), SS_Log::ERR); } } return $result; }
Config::inst()->update('Email', 'admin_email', $email_from); //Register Shortcodes ShortcodeParser::get()->register('Sched', array('Page', 'SchedShortCodeHandler')); ShortcodeParser::get()->register('outlink', array('Page', 'ExternalLinkShortCodeHandler')); ShortcodeParser::get()->register('icon', array('Page', 'IconShortCodeHandler')); //cache configuration /* SS_Cache::add_backend('two-level', 'Two-Levels', array( 'slow_backend' => 'File', 'fast_backend' => 'Apc', 'slow_backend_options' => array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache') )); SS_Cache::pick_backend('two-level', 'any', 10); // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags */ SS_Cache::add_backend('file-level', 'File', array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')); SS_Cache::pick_backend('file-level', 'any', 10); SS_Cache::set_cache_lifetime($for = 'cache_entity_count', $lifetime = 3600, $priority = 100); //entity counter extension Object::add_extension('HomePage_Controller', 'EntityCounter'); Object::add_extension('AnniversaryPage_Controller', 'EntityCounter'); Object::add_extension('Group', 'GroupDecorator'); Object::add_extension('SecurityAdmin', 'SecurityAdminExtension'); //Force cache to flush on page load if in Dev mode (prevents needing ?flush=1 on the end of a URL) if (Director::isDev()) { //Set default login Security::setDefaultAdmin('admin', 'pass'); } /* TinyMCE Configuration */ $tinyMCE = HtmlEditorConfig::get('cms'); $tinyMCE->setOption('extended_valid_elements', '@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,i,em,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align|name],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]');
<?php if (Director::isLive()) { Controller::add_extension('SS_MinifiedResponseExtension'); Requirements::set_backend(new Minify_Requirements_Backend()); if (defined('MINIFY_CACHE_BACKEND') && defined('MINIFY_CACHE_LIFETIME')) { $backend = unserialize(MINIFY_CACHE_BACKEND); SS_Cache::add_backend('MINIFY_CACHE_BACKEND', $backend['Type'], $backend['Options']); SS_Cache::set_cache_lifetime('MINIFY_CACHE_BACKEND', MINIFY_CACHE_LIFETIME, 100); SS_Cache::pick_backend('MINIFY_CACHE_BACKEND', 'MINIFY_CACHE', 100); } }
<?php ModelAdmin::add_extension("ImportAdminExtension"); ModelAdmin::add_extension("ExportAdminExtension"); $remove = Config::inst()->get('ModelAdmin', 'removelegacyimporters'); if ($remove === "scaffolded") { Config::inst()->update("ModelAdmin", 'model_importers', array()); } //cache mappings forever SS_Cache::set_cache_lifetime('gridfieldimporter', null);
<?php /** * * @author: Nicolaas - modules [at] sunnysideup.co.nz **/ // optional settings that may be useful //setlocale (LC_TIME, 'en_NZ@dollar', 'en_NZ.UTF-8', 'en_NZ', 'nz', 'nz'); //date_default_timezone_set("NZ"); // CACHING RECOMMENDATION - you can overrule that in the mysite _config.php file... //one week = 604800 (60 * 60 * 24 * 7) //last param is priority SS_Cache::set_cache_lifetime('any', 604800); CMSMenu::add_menu_item('refresh', 'Refresh Website', 'shoppingcart/clear/?flush=all', $controllerClass = null, $priority = 2.9, array("target" => "_blank")); CMSMenu::remove_menu_item('CMSPageAddController_Products');
<?php SS_Cache::add_backend('LatestTweets_cache', 'File', array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')); SS_Cache::set_cache_lifetime('LatestTweets_cache', 1800, 10); SS_Cache::pick_backend('LatestTweets_cache', 'any', 10); Object::add_extension('SiteConfig', 'LaTw_SiteConfig_Extension'); Object::add_extension('Page_Controller', 'LaTw_Page_Controller_Extension');
public function __construct() { SS_Cache::set_cache_lifetime(self::$cache_key, 3600); }
<?php global $project; $project = 'mysite'; global $database; $database = 'silverstripe_webdevelopment_com'; require_once "conf/ConfigureFromEnv.php"; date_default_timezone_set('Pacific/Auckland'); //set cache to 72 hours SS_Cache::set_cache_lifetime('any', 60 * 60 * 72); if (Director::isLive()) { SS_Log::add_writer(new SS_LogEmailWriter('*****@*****.**'), SS_Log::ERR); } else { //BasicAuth::protect_entire_site(); see config.yml } HtmlEditorConfig::get('cms')->setOption('valid_styles', array('*' => 'color,font-weight,font-style,text-decoration')); HtmlEditorConfig::get('cms')->setOption('paste_as_text', true); HtmlEditorConfig::get('cms')->setOption('paste_text_sticky', true); HtmlEditorConfig::get('cms')->setOption('paste_text_sticky_default', true);
Config::inst()->update('WidgetSetAdmin', 'menuSortIndex', 20); Config::inst()->update('ReportAdmin', 'menuSortIndex', 30); Config::inst()->update('AssetAdmin', 'menuSortIndex', 1); Config::inst()->update('SecurityAdmin', 'menuSortIndex', 30); Config::inst()->update('CMSSettingsController', 'menuSortIndex', 1); // ---------------------------------------------------------------------------- // Dirty bugfixes .... // ---------------------------------------------------------------------------- if (array_key_exists('Email', $_POST)) { $_POST['Email'] = SilvercartTools::prepareEmailAddress($_POST['Email']); } $cacheDirectories = array('cacheblock' => getTempFolder() . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'cacheblock', 'silvercart' => getTempFolder() . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'silvercart'); if (Director::isDev()) { $cachelifetime = 1; } else { $cachelifetime = 86400; } foreach ($cacheDirectories as $cacheName => $cacheDirectory) { SilvercartCleanCacheTask::register_cache_directory($cacheDirectory); if (!is_dir($cacheDirectory)) { mkdir($cacheDirectory); } SS_Cache::add_backend($cacheName, 'File', array('cache_dir' => $cacheDirectory, 'hashed_directory_level' => 1)); SS_Cache::set_cache_lifetime($cacheName, $cachelifetime); SS_Cache::pick_backend($cacheName, $cacheName); } SS_Cache::set_cache_lifetime('aggregate', $cachelifetime); /* * DO NOT ENABLE THE CREATION OF TEST DATA IN DEV MODE HERE! * THIS SHOULD BE PROJECT SPECIFIC. */
/** * Returns the caching factory * * @return Zend_Cache_Core */ protected function getCache() { // Determine cache parameters $backend = self::config()->cacheBackend; // Create default backend if not overridden if ($backend === 'DynamicCache') { $cacheDir = str_replace(array('%BASE_PATH%', '%ASSETS_PATH%'), array(BASE_PATH, ASSETS_PATH), self::config()->cacheDir); // Using own folder helps with separating page cache from other SS cached elements // TODO Use Filesystem::isAbsolute() once $_ENV['OS'] bug is fixed (should use getenv()) if ($cacheDir[0] !== '/') { $cacheDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . $cacheDir; } if (!is_dir($cacheDir)) { mkdir($cacheDir); } SS_Cache::add_backend('DynamicCacheStore', 'File', array('cache_dir' => $cacheDir)); SS_Cache::pick_backend('DynamicCacheStore', $backend, 1000); } // Set lifetime, allowing for 0 (infinite) lifetime if (($lifetime = self::config()->cacheDuration) !== null) { SS_Cache::set_cache_lifetime($backend, $lifetime); } // Get factory from this cache return SS_Cache::factory($backend); }
<?php global $project; $project = 'mysite'; // use the _ss_environment.php file for configuration require_once 'conf/ConfigureFromEnv.php'; // set default language i18n::set_locale('en_US'); define('PROJECT_THIRDPARTY_DIR', project() . '/thirdparty'); define('PROJECT_THIRDPARTY_PATH', BASE_PATH . '/' . PROJECT_THIRDPARTY_DIR); if (SS_IS_TEST_ENV) { BasicAuth::protect_entire_site(true); } if (Director::isLive()) { if (strpos(Director::absoluteBaseURL(), 'silverstripe-europe.org') !== false || strpos(Director::absoluteBaseURL(), 'www') !== false) { $response = new SS_HTTPResponse(); $response->redirect('https://stripecon.eu', 301); HTTP::add_cache_headers($response); $response->output(); die; } // we are in live mode, send errors per email, set cache and force WWW HTTP::set_cache_age(3600); // HTTP Header for CloudFlare Caching SS_Cache::set_cache_lifetime('any', 10800); // Serverside cache to 3 hours. SS_Log::add_writer(new SS_LogEmailWriter('*****@*****.**'), SS_Log::ERR); } Config::inst()->update('HtmlEditorField', 'use_gzip', false);
*/ ContentController::add_extension('CustomHtmlFormPage_Controller'); Security::add_extension('CustomHtmlFormPage_Controller'); SiteConfig::add_extension('CustomHtmlFormConfiguration'); $cacheBaseDir = getTempFolder() . DIRECTORY_SEPARATOR . 'cache'; $cacheDir = $cacheBaseDir . DIRECTORY_SEPARATOR . 'CustomHtmlForm'; if (Director::isDev()) { $cachelifetime = 1; } else { $cachelifetime = 86400; } if (!is_dir($cacheDir)) { if (!is_dir($cacheBaseDir)) { mkdir($cacheBaseDir); } mkdir($cacheDir); } if (class_exists('SilvercartCleanCacheTask')) { SilvercartCleanCacheTask::register_cache_directory($cacheDir); } SS_Cache::set_cache_lifetime('CustomHtmlForm', $cachelifetime); SS_Cache::add_backend('CustomHtmlForm', 'File', array('cache_dir' => $cacheDir, 'hashed_directory_level' => 2)); SS_Cache::pick_backend('CustomHtmlForm', 'CustomHtmlForm'); if (class_exists('RequirementsEngine')) { RequirementsEngine::registerJsFile('customhtmlform/script/jquery.js'); RequirementsEngine::registerJsFile('customhtmlform/script/jquery.scrollTo.min.js'); RequirementsEngine::registerJsFile('customhtmlform/script/jquery.pixeltricks.forms.checkFormData.js'); RequirementsEngine::registerJsFile('customhtmlform/script/jquery.pixeltricks.forms.events.js'); RequirementsEngine::registerJsFile('customhtmlform/script/jquery.pixeltricks.forms.validator.js'); RequirementsEngine::registerJsFile(SAPPHIRE_DIR . "/javascript/i18n.js"); }
<?php global $project; $project = 'mysite'; global $database; $database = 'eamon'; require_once 'conf/ConfigureFromEnv.php'; // Log notices if (defined('MY_SS_ERROR_LOG')) { SS_Log::add_writer(new SS_LogFileWriter(MY_SS_ERROR_LOG), SS_Log::NOTICE, '<='); } // Set the site locale i18n::set_locale('en_GB'); CMSMenu::remove_menu_item('ReportAdmin'); // Set cache life $devCacheLife = -1; $liveCacheLife = 60 * 5; // 5 min $cacheLife = Director::isDev() ? $devCacheLife : $liveCacheLife; SS_Cache::set_cache_lifetime(Cached_PageDataUtil::CACHE_NAME, $cacheLife, 100);
<?php define('INSTAGRAM_DIR', ltrim(Director::makeRelative(realpath(__DIR__)), DIRECTORY_SEPARATOR)); // Sets the cache to one day. SS_Cache::set_cache_lifetime('InstagramPage', 86400);
/** * Returns the caching factory * * @return Zend_Cache_Core */ protected function getCache() { // Determine cache parameters $backend = self::config()->cacheBackend; // Create default backend if not overridden if ($backend === 'DynamicCache') { // Using own folder helps with separating page cache from other SS cached elements $cacheDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'dynamic_cache'; if (!is_dir($cacheDir)) { mkdir($cacheDir); } SS_Cache::add_backend('DynamicCacheStore', 'File', array('cache_dir' => $cacheDir)); SS_Cache::pick_backend('DynamicCacheStore', $backend, 1000); } // Set lifetime, allowing for 0 (infinite) lifetime if (($lifetime = self::config()->cacheDuration) !== null) { SS_Cache::set_cache_lifetime($backend, $lifetime); } // Get factory from this cache return SS_Cache::factory($backend); }
<?php /** * 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> * * @package framework * @subpackage core */ ShortcodeParser::get('default')->register('file_link', array('File', 'handle_shortcode'))->register('embed', array('Oembed', 'handle_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 SS_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';
<?php global $project; $project = 'mysite'; global $database; $database = 'somepainter'; require_once 'conf/ConfigureFromEnv.php'; // Set timezone date_default_timezone_set('Australia/Melbourne'); // Set the site locale i18n::set_locale('en_AU'); //Log notices if (defined('MY_SS_ERROR_LOG')) { SS_Log::add_writer(new SS_LogFileWriter(MY_SS_ERROR_LOG), SS_Log::NOTICE, '<='); } // Configure Admin CMSMenu::remove_menu_item('ReportAdmin'); CMSMenu::remove_menu_item('CMSPagesController'); CMSMenu::remove_menu_item('AssetAdmin'); CMSMenu::remove_menu_item('SecurityAdmin'); CMSMenu::remove_menu_item('CMSSettingsController'); // Configure cache $liveCacheLife = 60 * 60; // 60 minutes $devCacheLife = -1; // disabled $cacheLife = Director::isDev() ? $devCacheLife : $liveCacheLife; SS_Cache::set_cache_lifetime(EventsController::EVENTS_CACHE_NAME, $cacheLife, 100); SS_Cache::set_cache_lifetime(EventsController::CONFIG_CACHE_NAME, $cacheLife, 100);
protected function _reset($cacheOn = true) { $this->data = new SSViewerCacheBlockTest_Model(); SS_Cache::factory('cacheblock')->clean(); SS_Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1); }
<?php /** * Dynamic Translations module for SilverStripe */ // Dynamic translations should never time-out SS_Cache::set_cache_lifetime('DynamicTranslations', null, 100);
<?php if (($RESTRICTED_OBJECTS_DIR = basename(dirname(__FILE__))) != 'restrictedobjects') { die("The restricted objects module must be installed in /restrictedobjects, not {$RESTRICTED_OBJECTS_DIR}"); } if (!class_exists('MultiValueField')) { die('The restricted objects module requires the multivaluefield module from http://github.com/nyeholt/silverstripe-multivaluefield'); } Director::addRules(100, array('Security/logout' => 'RestrictedSecurityController')); Object::add_extension('Member', 'RestrictedMember'); // if we're in Dev, and have set "no initial checks", which is common during testing, disable perms if ((Director::isDev() || Director::is_cli()) && isset($_GET['disable_perms'])) { Restrictable::set_enabled(false); } SS_Cache::set_cache_lifetime('restricted_perms', 3600);
<?php /** * Default configuration settings for Tumblr Feed module. * * You should not put your own configurations here; use your * mysite/_config.php file * * @package tumblrfeed */ SS_Cache::add_backend('tumblr_api_cache', 'File', array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')); SS_Cache::set_cache_lifetime('tumblr_api_cache', 1800, 10); SS_Cache::pick_backend('tumblr_api_cache', 'any', 10); Object::add_extension('SiteConfig', 'TumblrSiteConfigExtension');