Commit 32d82f59 by Paul Klimov

Code style at redis readme fixed.

parent ece5f0b8
...@@ -44,17 +44,17 @@ to the require section of your composer.json. ...@@ -44,17 +44,17 @@ to the require section of your composer.json.
Using the Cache component Using the Cache component
------------------------- -------------------------
To use the `Cache` component, in addtition to configuring the connection as described above, To use the `Cache` component, in addition to configuring the connection as described above,
you also have to configure the `cache` component to be `yii\redis\Cache`: you also have to configure the `cache` component to be `yii\redis\Cache`:
```php ```php
return [ return [
//.... //....
'components' => [ 'components' => [
// ... // ...
'cache' => [ 'cache' => [
'class' => 'yii\redis\Cache', 'class' => 'yii\redis\Cache',
], ],
] ]
]; ];
``` ```
...@@ -66,15 +66,15 @@ cache component (no connection application component needs to be configured in t ...@@ -66,15 +66,15 @@ cache component (no connection application component needs to be configured in t
return [ return [
//.... //....
'components' => [ 'components' => [
// ... // ...
'cache' => [ 'cache' => [
'class' => 'yii\redis\Cache', 'class' => 'yii\redis\Cache',
'redis' => [ 'redis' => [
'hostname' => 'localhost', 'hostname' => 'localhost',
'port' => 6379, 'port' => 6379,
'database' => 0, 'database' => 0,
], ],
], ],
] ]
]; ];
``` ```
...@@ -89,10 +89,10 @@ you also have to configure the `session` component to be `yii\redis\Session`: ...@@ -89,10 +89,10 @@ you also have to configure the `session` component to be `yii\redis\Session`:
return [ return [
//.... //....
'components' => [ 'components' => [
// ... // ...
'session' => [ 'session' => [
'class' => 'yii\redis\Session', 'class' => 'yii\redis\Session',
], ],
] ]
]; ];
``` ```
...@@ -104,15 +104,15 @@ cache component (no connection application component needs to be configured in t ...@@ -104,15 +104,15 @@ cache component (no connection application component needs to be configured in t
return [ return [
//.... //....
'components' => [ 'components' => [
// ... // ...
'session' => [ 'session' => [
'class' => 'yii\redis\Session', 'class' => 'yii\redis\Session',
'redis' => [ 'redis' => [
'hostname' => 'localhost', 'hostname' => 'localhost',
'port' => 6379, 'port' => 6379,
'database' => 0, 'database' => 0,
], ],
], ],
] ]
]; ];
``` ```
...@@ -134,29 +134,29 @@ The following is an example model called `Customer`: ...@@ -134,29 +134,29 @@ The following is an example model called `Customer`:
```php ```php
class Customer extends \yii\redis\ActiveRecord class Customer extends \yii\redis\ActiveRecord
{ {
/** /**
* @return array the list of attributes for this record * @return array the list of attributes for this record
*/ */
public function attributes() public function attributes()
{ {
return ['id', 'name', 'address', 'registration_date']; return ['id', 'name', 'address', 'registration_date'];
} }
/** /**
* @return ActiveRelation defines a relation to the Order record (can be in other database, e.g. elasticsearch or sql) * @return ActiveRelation defines a relation to the Order record (can be in other database, e.g. elasticsearch or sql)
*/ */
public function getOrders() public function getOrders()
{ {
return $this->hasMany(Order::className(), ['customer_id' => 'id']); return $this->hasMany(Order::className(), ['customer_id' => 'id']);
} }
/** /**
* Defines a scope that modifies the `$query` to return only active(status = 1) customers * Defines a scope that modifies the `$query` to return only active(status = 1) customers
*/ */
public static function active($query) public static function active($query)
{ {
$query->andWhere(array('status' => 1)); $query->andWhere(array('status' => 1));
} }
} }
``` ```
......
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