MINOR Documentation in SS_Cache

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114551 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-12-05 19:46:21 +00:00
parent df08da0f49
commit ead9dce351

17
cache/Cache.php vendored
View File

@ -3,7 +3,7 @@
* SS_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. * 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) * A {@link Zend_Cache} has both a frontend (determines how to get the value to cache, and how to serialize it for storage)
* and a backend (handles the actual storage). * and a backend (handles the actual storage).
* *
* Rather than require library code to specify the backend directly, cache consumers provide a name for the cache * Rather than require library code to specify the backend directly, cache consumers provide a name for the cache
@ -15,6 +15,7 @@
* *
* USING A CACHE * USING A CACHE
* *
* <code>
* $cache = SS_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))) { * if (!($result = $cache->load($cachekey))) {
@ -23,6 +24,7 @@
* } * }
* *
* return $result; * return $result;
* </code>
* *
* Normally there's no need to remove things from the cache - the cache backends clear out entries based on age & maximum * Normally there's no need to remove things from the cache - the cache backends clear out entries based on age & maximum
* allocated storage. If you include the version of the object in the cache key, even object changes don't need any invalidation * allocated storage. If you include the version of the object in the cache key, even object changes don't need any invalidation
@ -31,18 +33,22 @@
* *
* (in _config.php) * (in _config.php)
* *
* <code>
* if (Director::isDev()) SS_Cache::set_cache_lifetime('any', -1, 100); * if (Director::isDev()) SS_Cache::set_cache_lifetime('any', -1, 100);
* </code>
* *
* USING MEMCACHED AS STORE * USING MEMCACHED AS STORE
* *
* (in _config.php) * (in _config.php)
* *
* <code>
* SS_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' => '' ) * array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 5, 'retry_interval' => 15, 'status' => true, 'failure_callback' => '' )
* ); * );
* *
* SS_Cache::pick_backend('primary_memcached', 'any', 10); * 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 * SS_Cache::pick_backend('default', 'aggregate', 20); // Aggregate needs a backend with tag support, which memcached doesn't provide
* </code>
* *
* USING APC AND FILE AS TWO LEVEL STORE * USING APC AND FILE AS TWO LEVEL STORE
* *
@ -55,6 +61,7 @@
* )); * ));
* *
* 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::pick_backend('two-level', 'any', 10); // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags
* </code>
* *
* @author hfried * @author hfried
* @package sapphire * @package sapphire
@ -136,15 +143,18 @@ class SS_Cache {
* *
* -- Cache a calculation * -- Cache a calculation
* *
* <code>
* if (!($result = $cache->load($cachekey))) { * if (!($result = $cache->load($cachekey))) {
* $result = caluate some how; * $result = caluate some how;
* $cache->save($result); * $cache->save($result);
* } * }
* *
* return $result; * return $result;
* </code>
* *
* -- Cache captured output * -- Cache captured output
* *
* <code>
* if (!($cache->start($cachekey))) { * if (!($cache->start($cachekey))) {
* *
* // output everything as usual * // output everything as usual
@ -153,14 +163,19 @@ class SS_Cache {
* *
* $cache->end(); // output buffering ends * $cache->end(); // output buffering ends
* } * }
* </code>
* *
* -- Invalidate an element * -- Invalidate an element
* *
* <code>
* $cache->remove($cachekey); * $cache->remove($cachekey);
* </code>
* *
* -- Clear the cache (warning - this clears the entire backend, not just this named cache partition) * -- Clear the cache (warning - this clears the entire backend, not just this named cache partition)
* *
* <code>
* $cache->clean(Zend_Cache::CLEANING_MODE_ALL); * $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
* </code>
* *
* See the Zend_Cache documentation at http://framework.zend.com/manual/en/zend.cache.html for more * See the Zend_Cache documentation at http://framework.zend.com/manual/en/zend.cache.html for more
* *