From 8afcd186f08c348de4537ed1a13a429016cb88fd Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 2 Feb 2010 04:06:51 +0000 Subject: [PATCH] APICHANGE: rename the class "Cache" to "SS_Cache" (ref ticket: #4997) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97996 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- cache/Cache.php | 18 +++++++++--------- core/SSViewer.php | 4 ++-- core/model/Aggregate.php | 2 +- tests/CacheTest.php | 14 +++++++------- tests/SSViewerCacheBlockTest.php | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cache/Cache.php b/cache/Cache.php index 587564f0f..9e457e3c6 100644 --- a/cache/Cache.php +++ b/cache/Cache.php @@ -1,7 +1,7 @@ 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(); diff --git a/core/SSViewer.php b/core/SSViewer.php index 3435edd90..11a044229 100755 --- a/core/SSViewer.php +++ b/core/SSViewer.php @@ -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']; @@ -644,7 +644,7 @@ class SSViewer_FromString extends SSViewer { $val = ""; $valStack = array(); - $cache = Cache::factory('cacheblock'); + $cache = SS_Cache::factory('cacheblock'); include($tmpFile); unlink($tmpFile); diff --git a/core/model/Aggregate.php b/core/model/Aggregate.php index c3e3e519b..f191d645a 100644 --- a/core/model/Aggregate.php +++ b/core/model/Aggregate.php @@ -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 */ diff --git a/tests/CacheTest.php b/tests/CacheTest.php index ce513d7a9..205eda05b 100644 --- a/tests/CacheTest.php +++ b/tests/CacheTest.php @@ -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'); diff --git a/tests/SSViewerCacheBlockTest.php b/tests/SSViewerCacheBlockTest.php index f332cd7cc..fad4614fc 100644 --- a/tests/SSViewerCacheBlockTest.php +++ b/tests/SSViewerCacheBlockTest.php @@ -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) {