Commit 3eae6942 by Carsten Brandt

improve cache phpdoc

parent 75b1f481
...@@ -11,9 +11,9 @@ use yii\base\Component; ...@@ -11,9 +11,9 @@ use yii\base\Component;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
/** /**
* Cache is the base class for cache classes supporting different cache storage implementation. * Cache is the base class for cache classes supporting different cache storage implementations.
* *
* A data item can be stored in cache by calling [[set()]] and be retrieved back * A data item can be stored in the cache by calling [[set()]] and be retrieved back
* later (in the same or different request) by [[get()]]. In both operations, * later (in the same or different request) by [[get()]]. In both operations,
* a key identifying the data item is required. An expiration time and/or a [[Dependency|dependency]] * a key identifying the data item is required. An expiration time and/or a [[Dependency|dependency]]
* can also be specified when calling [[set()]]. If the data item expires or the dependency * can also be specified when calling [[set()]]. If the data item expires or the dependency
...@@ -21,23 +21,23 @@ use yii\helpers\StringHelper; ...@@ -21,23 +21,23 @@ use yii\helpers\StringHelper;
* *
* A typical usage pattern of cache is like the following: * A typical usage pattern of cache is like the following:
* *
* ~~~ * ```php
* $key = 'demo'; * $key = 'demo';
* $data = $cache->get($key); * $data = $cache->get($key);
* if ($data === false) { * if ($data === false) {
* // ...generate $data here... * // ...generate $data here...
* $cache->set($key, $data, $duration, $dependency); * $cache->set($key, $data, $duration, $dependency);
* } * }
* ~~~ * ```
* *
* Because Cache implements the ArrayAccess interface, it can be used like an array. For example, * Because Cache implements the ArrayAccess interface, it can be used like an array. For example,
* *
* ~~~ * ```php
* $cache['foo'] = 'some data'; * $cache['foo'] = 'some data';
* echo $cache['foo']; * echo $cache['foo'];
* ~~~ * ```
* *
* Derived classes should implement the following methods: * Derived classes should implement the following methods which do the actual cache storage operations:
* *
* - [[getValue()]]: retrieve the value with a key (if any) from cache * - [[getValue()]]: retrieve the value with a key (if any) from cache
* - [[setValue()]]: store the value with a key into cache * - [[setValue()]]: store the value with a key into cache
......
...@@ -23,13 +23,13 @@ use yii\di\Instance; ...@@ -23,13 +23,13 @@ use yii\di\Instance;
* *
* The following example shows how you can configure the application to use DbCache: * The following example shows how you can configure the application to use DbCache:
* *
* ~~~ * ```php
* 'cache' => [ * 'cache' => [
* 'class' => 'yii\caching\DbCache', * 'class' => 'yii\caching\DbCache',
* // 'db' => 'mydb', * // 'db' => 'mydb',
* // 'cacheTable' => 'my_cache', * // 'cacheTable' => 'my_cache',
* ] * ]
* ~~~ * ```
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment