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
b3be3710
Commit
b3be3710
authored
May 16, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhanced cache command.
parent
8d23d4c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
CacheController.php
yii/console/controllers/CacheController.php
+22
-3
No files found.
yii/console/controllers/CacheController.php
View file @
b3be3710
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
namespace
yii\console\controllers
;
namespace
yii\console\controllers
;
use
Yii
;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
yii\console\Exception
;
use
yii\console\Exception
;
use
yii\caching\Cache
;
use
yii\caching\Cache
;
...
@@ -19,10 +20,28 @@ use yii\caching\Cache;
...
@@ -19,10 +20,28 @@ use yii\caching\Cache;
*/
*/
class
CacheController
extends
Controller
class
CacheController
extends
Controller
{
{
/**
* Lists the caches that can be flushed.
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$this
->
forward
(
'help/index'
,
array
(
'-args'
=>
array
(
'cache/flush'
)));
$caches
=
array
();
$components
=
Yii
::
$app
->
getComponents
();
foreach
(
$components
as
$name
=>
$component
)
{
if
(
$component
instanceof
Cache
)
{
$caches
[
$name
]
=
get_class
(
$component
);
}
elseif
(
is_array
(
$component
)
&&
isset
(
$component
[
'class'
])
&&
strpos
(
$component
[
'class'
],
'Cache'
)
!==
false
)
{
$caches
[
$name
]
=
$component
[
'class'
];
}
}
if
(
!
empty
(
$caches
))
{
echo
"The following caches can be flushed:
\n\n
"
;
foreach
(
$caches
as
$name
=>
$class
)
{
echo
" *
$name
:
$class
\n
"
;
}
}
else
{
echo
"No cache is used.
\n
"
;
}
}
}
/**
/**
...
@@ -34,7 +53,7 @@ class CacheController extends Controller
...
@@ -34,7 +53,7 @@ class CacheController extends Controller
public
function
actionFlush
(
$component
=
'cache'
)
public
function
actionFlush
(
$component
=
'cache'
)
{
{
/** @var $cache Cache */
/** @var $cache Cache */
$cache
=
\
Yii
::
$app
->
getComponent
(
$component
);
$cache
=
Yii
::
$app
->
getComponent
(
$component
);
if
(
!
$cache
||
!
$cache
instanceof
Cache
)
{
if
(
!
$cache
||
!
$cache
instanceof
Cache
)
{
throw
new
Exception
(
'Application component "'
.
$component
.
'" is not defined or not a cache.'
);
throw
new
Exception
(
'Application component "'
.
$component
.
'" is not defined or not a cache.'
);
}
}
...
...
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