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
613d3071
Commit
613d3071
authored
Sep 23, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #5106: Refactored query caching to not load cache component when query…
Fixes #5106: Refactored query caching to not load cache component when query caching is not used at all.
parent
d6b7a5e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
Command.php
framework/db/Command.php
+1
-22
Connection.php
framework/db/Connection.php
+19
-3
No files found.
framework/db/Command.php
View file @
613d3071
...
...
@@ -778,27 +778,6 @@ class Command extends Component
}
/**
* Returns the effective query cache information.
* @return array the current query cache information, or null if query cache is not used.
*/
private
function
getQueryCacheInfo
()
{
$info
=
$this
->
db
->
getQueryCacheInfo
();
if
(
is_array
(
$info
))
{
if
(
$this
->
queryCacheDuration
!==
null
)
{
$info
[
1
]
=
$this
->
queryCacheDuration
;
}
if
(
$this
->
queryCacheDependency
!==
null
)
{
$info
[
2
]
=
$this
->
queryCacheDependency
;
}
if
(
$info
[
1
]
!==
null
&&
$info
[
1
]
>=
0
)
{
return
$info
;
}
}
return
null
;
}
/**
* Performs the actual DB query of a SQL statement.
* @param string $method method of PDOStatement to be called
* @param integer $fetchMode the result fetch mode. Please refer to [PHP manual](http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php)
...
...
@@ -813,7 +792,7 @@ class Command extends Component
Yii
::
info
(
$rawSql
,
'yii\db\Command::query'
);
if
(
$method
!==
''
)
{
$info
=
$this
->
getQueryCacheInfo
(
);
$info
=
$this
->
db
->
getQueryCacheInfo
(
$this
->
queryCacheDuration
,
$this
->
queryCacheDependency
);
if
(
is_array
(
$info
))
{
/* @var $cache \yii\caching\Cache */
$cache
=
$info
[
0
];
...
...
framework/db/Connection.php
View file @
613d3071
...
...
@@ -465,22 +465,38 @@ class Connection extends Component
/**
* Returns the current query cache information.
* This method is used internally by [[Command]].
* @param integer $duration the preferred caching duration. If null, it will be ignored.
* @param \yii\caching\Dependency $dependency the preferred caching dependency. If null, it will be ignored.
* @return array the current query cache information, or null if query cache is not enabled.
* @internal
*/
public
function
getQueryCacheInfo
()
public
function
getQueryCacheInfo
(
$duration
,
$dependency
)
{
if
(
!
$this
->
enableQueryCache
)
{
return
null
;
}
$info
=
end
(
$this
->
_queryCacheInfo
);
if
(
$this
->
enableQueryCache
)
{
if
(
is_array
(
$info
))
{
if
(
$duration
===
null
)
{
$duration
=
$info
[
0
];
}
if
(
$dependency
===
null
)
{
$dependency
=
$info
[
1
];
}
}
if
(
$duration
===
0
||
$duration
>
0
)
{
if
(
is_string
(
$this
->
queryCache
)
&&
Yii
::
$app
)
{
$cache
=
Yii
::
$app
->
get
(
$this
->
queryCache
,
false
);
}
else
{
$cache
=
$this
->
queryCache
;
}
if
(
$cache
instanceof
Cache
)
{
return
is_array
(
$info
)
?
[
$cache
,
$info
[
0
],
$info
[
1
]]
:
[
$cache
,
null
,
null
];
return
[
$cache
,
$duration
,
$dependency
];
}
}
return
null
;
}
...
...
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