Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
32d82f59
Commit
32d82f59
authored
Jan 14, 2014
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code style at redis readme fixed.
parent
ece5f0b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
50 deletions
+50
-50
README.md
extensions/redis/README.md
+50
-50
No files found.
extensions/redis/README.md
View file @
32d82f59
...
...
@@ -44,17 +44,17 @@ to the require section of your composer.json.
Using the Cache component
-------------------------
To use the
`Cache`
component, in add
t
ition 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`
:
```
php
return
[
//....
'components'
=>
[
// ...
'cache'
=>
[
'class'
=>
'yii\redis\Cache'
,
],
// ...
'cache'
=>
[
'class'
=>
'yii\redis\Cache'
,
],
]
];
```
...
...
@@ -66,15 +66,15 @@ cache component (no connection application component needs to be configured in t
return
[
//....
'components'
=>
[
// ...
'cache'
=>
[
'class'
=>
'yii\redis\Cache'
,
'redis'
=>
[
'hostname'
=>
'localhost'
,
'port'
=>
6379
,
'database'
=>
0
,
],
],
// ...
'cache'
=>
[
'class'
=>
'yii\redis\Cache'
,
'redis'
=>
[
'hostname'
=>
'localhost'
,
'port'
=>
6379
,
'database'
=>
0
,
],
],
]
];
```
...
...
@@ -89,10 +89,10 @@ you also have to configure the `session` component to be `yii\redis\Session`:
return
[
//....
'components'
=>
[
// ...
'session'
=>
[
'class'
=>
'yii\redis\Session'
,
],
// ...
'session'
=>
[
'class'
=>
'yii\redis\Session'
,
],
]
];
```
...
...
@@ -104,15 +104,15 @@ cache component (no connection application component needs to be configured in t
return
[
//....
'components'
=>
[
// ...
'session'
=>
[
'class'
=>
'yii\redis\Session'
,
'redis'
=>
[
'hostname'
=>
'localhost'
,
'port'
=>
6379
,
'database'
=>
0
,
],
],
// ...
'session'
=>
[
'class'
=>
'yii\redis\Session'
,
'redis'
=>
[
'hostname'
=>
'localhost'
,
'port'
=>
6379
,
'database'
=>
0
,
],
],
]
];
```
...
...
@@ -134,29 +134,29 @@ The following is an example model called `Customer`:
```
php
class
Customer
extends
\yii\redis\ActiveRecord
{
/**
* @return array the list of attributes for this record
*/
public
function
attributes
()
{
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)
*/
public
function
getOrders
()
{
return
$this
->
hasMany
(
Order
::
className
(),
[
'customer_id'
=>
'id'
]);
}
/**
* Defines a scope that modifies the `$query` to return only active(status = 1) customers
*/
public
static
function
active
(
$query
)
{
$query
->
andWhere
(
array
(
'status'
=>
1
));
}
/**
* @return array the list of attributes for this record
*/
public
function
attributes
()
{
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)
*/
public
function
getOrders
()
{
return
$this
->
hasMany
(
Order
::
className
(),
[
'customer_id'
=>
'id'
]);
}
/**
* Defines a scope that modifies the `$query` to return only active(status = 1) customers
*/
public
static
function
active
(
$query
)
{
$query
->
andWhere
(
array
(
'status'
=>
1
));
}
}
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment