mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
APICHANGE: rename the class "Cache" to "SS_Cache" (ref ticket: #4997) (from r97996)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102564 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
98de6165ea
commit
25ad651966
18
cache/Cache.php
vendored
18
cache/Cache.php
vendored
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Cache provides a bunch of static functions wrapping the Zend_Cache system in something a little more
|
||||
* SS_Cache provides a bunch of static functions wrapping the Zend_Cache system in something a little more
|
||||
* easy to use with the SilverStripe config system.
|
||||
*
|
||||
* A Zend_Cache has both a frontend (determines how to get the value to cache, and how to serialize it for storage)
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* USING A CACHE
|
||||
*
|
||||
* $cache = Cache::factory('foo') ; // foo is any name (try to be specific), and is used to get configuration & storage info
|
||||
* $cache = SS_Cache::factory('foo') ; // foo is any name (try to be specific), and is used to get configuration & storage info
|
||||
*
|
||||
* if (!($result = $cache->load($cachekey))) {
|
||||
* $result = caluate some how;
|
||||
@ -32,34 +32,34 @@
|
||||
*
|
||||
* (in _config.php)
|
||||
*
|
||||
* if (Director::isDev()) Cache::set_cache_lifetime('any', -1, 100);
|
||||
* if (Director::isDev()) SS_Cache::set_cache_lifetime('any', -1, 100);
|
||||
*
|
||||
* USING MEMCACHED AS STORE
|
||||
*
|
||||
* (in _config.php)
|
||||
*
|
||||
* Cache::add_backend('primary_memcached', 'Memcached',
|
||||
* SS_Cache::add_backend('primary_memcached', 'Memcached',
|
||||
* array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 5, 'retry_interval' => 15, 'status' => true, 'failure_callback' => '' )
|
||||
* );
|
||||
*
|
||||
* Cache::pick_backend('primary_memcached', 'any', 10);
|
||||
* Cache::pick_backend('default', 'aggregate', 20); // Aggregate needs a backend with tag support, which memcached doesn't provide
|
||||
* SS_Cache::pick_backend('primary_memcached', 'any', 10);
|
||||
* SS_Cache::pick_backend('default', 'aggregate', 20); // Aggregate needs a backend with tag support, which memcached doesn't provide
|
||||
*
|
||||
* USING APC AND FILE AS TWO LEVEL STORE
|
||||
*
|
||||
* (in _config.php)
|
||||
*
|
||||
* Cache::add_backend('two-level', 'TwoLevels' array(
|
||||
* SS_Cache::add_backend('two-level', 'TwoLevels' array(
|
||||
* 'slow_backend' => 'File',
|
||||
* 'fast_backend' => 'Apc',
|
||||
* 'slow_backend_options' => array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')
|
||||
* ));
|
||||
*
|
||||
* Cache::pick_backend('two-level', 'any', 10); // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags
|
||||
* SS_Cache::pick_backend('two-level', 'any', 10); // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags
|
||||
*
|
||||
* @author hfried
|
||||
*/
|
||||
class Cache {
|
||||
class SS_Cache {
|
||||
|
||||
protected static $backends = array();
|
||||
protected static $backend_picks = array();
|
||||
|
@ -322,7 +322,7 @@ class SSViewer {
|
||||
public function process($item, $cache = null) {
|
||||
SSViewer::$topLevel[] = $item;
|
||||
|
||||
if (!$cache) $cache = Cache::factory('cacheblock');
|
||||
if (!$cache) $cache = SS_Cache::factory('cacheblock');
|
||||
|
||||
if(isset($this->chosenTemplates['main'])) {
|
||||
$template = $this->chosenTemplates['main'];
|
||||
@ -649,7 +649,7 @@ class SSViewer_FromString extends SSViewer {
|
||||
$val = "";
|
||||
$valStack = array();
|
||||
|
||||
$cache = Cache::factory('cacheblock');
|
||||
$cache = SS_Cache::factory('cacheblock');
|
||||
|
||||
include($tmpFile);
|
||||
unlink($tmpFile);
|
||||
|
@ -33,7 +33,7 @@ class Aggregate extends ViewableData {
|
||||
|
||||
/** Build & cache the cache object */
|
||||
protected static function cache() {
|
||||
return self::$cache ? self::$cache : (self::$cache = Cache::factory('aggregate'));
|
||||
return self::$cache ? self::$cache : (self::$cache = SS_Cache::factory('aggregate'));
|
||||
}
|
||||
|
||||
/** Clear the aggregate cache for a given type, or pass nothing to clear all aggregate caches */
|
||||
|
@ -3,25 +3,25 @@
|
||||
class CacheTest extends SapphireTest {
|
||||
|
||||
function testCacheBasics() {
|
||||
$cache = Cache::factory('test');
|
||||
$cache = SS_Cache::factory('test');
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
$this->assertEquals('Good', $cache->load('cachekey'));
|
||||
}
|
||||
|
||||
function testCacheCanBeDisabled() {
|
||||
Cache::set_cache_lifetime('test', -1, 10);
|
||||
SS_Cache::set_cache_lifetime('test', -1, 10);
|
||||
|
||||
$cache = Cache::factory('test');
|
||||
$cache = SS_Cache::factory('test');
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
$this->assertFalse($cache->load('cachekey'));
|
||||
}
|
||||
|
||||
function testCacheLifetime() {
|
||||
Cache::set_cache_lifetime('test', 4, 20);
|
||||
SS_Cache::set_cache_lifetime('test', 4, 20);
|
||||
|
||||
$cache = Cache::factory('test');
|
||||
$cache = SS_Cache::factory('test');
|
||||
|
||||
$cache->save('Good', 'cachekey');
|
||||
$this->assertEquals('Good', $cache->load('cachekey'));
|
||||
@ -32,8 +32,8 @@ class CacheTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testCacheSeperation() {
|
||||
$cache1 = Cache::factory('test1');
|
||||
$cache2 = Cache::factory('test2');
|
||||
$cache1 = SS_Cache::factory('test1');
|
||||
$cache2 = SS_Cache::factory('test2');
|
||||
|
||||
$cache1->save('Foo', 'cachekey');
|
||||
$cache2->save('Bar', 'cachekey');
|
||||
|
@ -22,8 +22,8 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
||||
protected function _reset($cacheOn = true) {
|
||||
$this->data = new SSViewerCacheBlockTest_Model();
|
||||
|
||||
Cache::factory('cacheblock')->clean();
|
||||
Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1);
|
||||
SS_Cache::factory('cacheblock')->clean();
|
||||
SS_Cache::set_cache_lifetime('cacheblock', $cacheOn ? 600 : -1);
|
||||
}
|
||||
|
||||
protected function _runtemplate($template, $data = null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user