From 967595fe8d89aa942af641bf7112e0f1bf7667ca Mon Sep 17 00:00:00 2001 From: Sean Madsen <sean@seanmadsen.com> Date: Tue, 8 Aug 2017 17:13:33 -0600 Subject: [PATCH] Improve markdown formatting --- docs/framework/cache.md | 114 ++++++++++++---------------------------- 1 file changed, 35 insertions(+), 79 deletions(-) diff --git a/docs/framework/cache.md b/docs/framework/cache.md index 18e2197e..c356dcaa 100644 --- a/docs/framework/cache.md +++ b/docs/framework/cache.md @@ -2,107 +2,63 @@ ## Using the cache -Civi::cache() is the simplest way to access the cache, automatically -using the default cache type (described below). The -CRM_Utils_Cache_Interface class lays out the methods for saving and -retrieving cached items. +`Civi::cache()` is the simplest way to access the cache, automatically using the default cache type (described below). The `CRM_Utils_Cache_Interface` class lays out the methods for saving and retrieving cached items. ### Methods -#### Set a cache value - -<div class="code panel" style="border-width: 1px;"> - -<div class="codeContent panelContent"> +* Set a cache value + ```php Civi::cache()->set('mykey', 'myvalue'); + ``` -</div> - -</div> - -#### Get a cached value - -<div class="code panel" style="border-width: 1px;"> - -<div class="codeContent panelContent"> +* Get a cached value + ```php Civi::cache()->get('mykey'); // returns the value, or NULL if not set + ``` -</div> - -</div> - -#### Delete a cached value - -<div class="code panel" style="border-width: 1px;"> - -<div class="codeContent panelContent"> +* Delete a cached value + ```php Civi::cache()->delete('mykey'); + ``` -</div> - -</div> - -#### Flush the entire cache - -<div class="code panel" style="border-width: 1px;"> - -<div class="codeContent panelContent"> +* Flush the entire cache + ```php Civi::cache()->flush(); - -</div> - -</div> + ``` ### Example -<div class="code panel" style="border-width: 1px;"> - -<div class="codeContent panelContent"> - - /** - * Finds the magic number, selecting one if necessary. - * - * @return int $magicNumber - * a magic number between 1 and 100 - */ - function findMagicNumber() { - $magicNumber = Civi::cache()->get('magicNumber'); - if (!$magicNumber) { - $magicNumber = rand(1,100); - Civi::cache()->set('magicNumber', $magicNumber); - } - return $magicNumber; - } - -</div> - -</div> +```php +/** + * Finds the magic number, selecting one if necessary. + * + * @return int $magicNumber + * a magic number between 1 and 100 + */ +function findMagicNumber() { + $magicNumber = Civi::cache()->get('magicNumber'); + if (!$magicNumber) { + $magicNumber = rand(1,100); + Civi::cache()->set('magicNumber', $magicNumber); + } + return $magicNumber; +} +``` ## Cache types -This is selected in civicrm.settings.php (at or near line 276), where -CIVICRM_DB_CACHE_CLASS is defined. - -#### ArrayCache - -This is the default, using an in-memory array. - -#### Memcache - -This is for the PHP Memcache extension. - -#### Memcached +This is selected in `civicrm.settings.php`, where `CIVICRM_DB_CACHE_CLASS` is defined. -This is for the PHP Memcached extension. +* "ArrayCache" - This is the default, using an in-memory array. -#### APCcache +* "Memcache" - This is for the PHP Memcache extension. -This is for the PHP APC extension. +* "Memcached" - This is for the PHP Memcached extension. -#### NoCache +* "APCcache" - This is for the PHP APC extension. -This caches nothing +* "NoCache" - This caches nothing -- GitLab