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
9cd67bb6
Commit
9cd67bb6
authored
Jan 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed query and schema caching renamings.
parent
9d75714b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
26 deletions
+15
-26
DbCache.php
framework/caching/DbCache.php
+6
-8
DbDependency.php
framework/caching/DbDependency.php
+3
-4
Command.php
framework/db/Command.php
+1
-1
Driver.php
framework/db/Driver.php
+5
-13
No files found.
framework/caching/DbCache.php
View file @
9cd67bb6
...
...
@@ -106,12 +106,11 @@ class DbCache extends Cache
->
from
(
$this
->
cacheTableName
)
->
where
(
'id = :id AND (expire = 0 OR expire > :time)'
,
array
(
':id'
=>
$key
,
':time'
=>
time
()));
$db
=
$this
->
getDbConnection
();
if
(
$db
->
queryCachingDuration
>=
0
)
{
if
(
$db
->
enableQueryCache
)
{
// temporarily disable and re-enable query caching
$duration
=
$db
->
queryCachingDuration
;
$db
->
queryCachingDuration
=
-
1
;
$db
->
enableQueryCache
=
false
;
$result
=
$query
->
createCommand
(
$db
)
->
queryScalar
();
$db
->
queryCachingDuration
=
$duration
;
$db
->
enableQueryCache
=
true
;
return
$result
;
}
else
{
return
$query
->
createCommand
(
$db
)
->
queryScalar
();
...
...
@@ -135,11 +134,10 @@ class DbCache extends Cache
->
andWhere
(
"expire = 0 OR expire > "
.
time
()
.
")"
);
$db
=
$this
->
getDbConnection
();
if
(
$db
->
queryCachingDuration
>=
0
)
{
$duration
=
$db
->
queryCachingDuration
;
$db
->
queryCachingDuration
=
-
1
;
if
(
$db
->
enableQueryCache
)
{
$db
->
enableQueryCache
=
false
;
$rows
=
$query
->
createCommand
(
$db
)
->
queryAll
();
$db
->
queryCachingDuration
=
$duration
;
$db
->
enableQueryCache
=
true
;
}
else
{
$rows
=
$query
->
createCommand
(
$db
)
->
queryAll
();
}
...
...
framework/caching/DbDependency.php
View file @
9cd67bb6
...
...
@@ -69,12 +69,11 @@ class DbDependency extends Dependency
{
$db
=
$this
->
getDbConnection
();
$command
=
$this
->
query
->
createCommand
(
$db
);
if
(
$db
->
queryCachingDuration
>=
0
)
{
if
(
$db
->
enableQueryCache
)
{
// temporarily disable and re-enable query caching
$duration
=
$db
->
queryCachingDuration
;
$db
->
queryCachingDuration
=
-
1
;
$db
->
enableQueryCache
=
false
;
$result
=
$command
->
queryRow
();
$db
->
queryCachingDuration
=
$duration
;
$db
->
enableQueryCache
=
true
;
}
else
{
$result
=
$command
->
queryRow
();
}
...
...
framework/db/Command.php
View file @
9cd67bb6
...
...
@@ -405,7 +405,7 @@ class Command extends \yii\base\Component
}
if
(
isset
(
$cache
))
{
$cache
->
set
(
$cacheKey
,
$result
,
$db
->
queryCach
ingDuration
,
$db
->
queryCaching
Dependency
);
$cache
->
set
(
$cacheKey
,
$result
,
$db
->
queryCach
eDuration
,
$db
->
queryCache
Dependency
);
\Yii
::
trace
(
'Saved query result in cache'
,
__CLASS__
);
}
...
...
framework/db/Driver.php
View file @
9cd67bb6
...
...
@@ -95,18 +95,13 @@ abstract class Driver extends \yii\base\Object
$realName
=
$db
->
expandTablePrefix
(
$name
);
// temporarily disable query caching
if
(
$db
->
queryCachingDuration
>=
0
)
{
$qcDuration
=
$db
->
queryCachingDuration
;
$db
->
queryCachingDuration
=
-
1
;
}
if
(
!
in_array
(
$name
,
$db
->
schemaCachingExclude
,
true
)
&&
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
/** @var $cache \yii\caching\Cache */
if
(
$db
->
enableSchemaCache
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
&&
!
in_array
(
$name
,
$db
->
schemaCacheExclude
,
true
))
{
$key
=
$this
->
getCacheKey
(
$name
);
if
(
$refresh
||
(
$table
=
$cache
->
get
(
$key
))
===
false
)
{
$table
=
$this
->
loadTableSchema
(
$realName
);
if
(
$table
!==
null
)
{
$cache
->
set
(
$key
,
$table
,
$db
->
schemaCach
ing
Duration
);
$cache
->
set
(
$key
,
$table
,
$db
->
schemaCach
e
Duration
);
}
}
$this
->
_tables
[
$name
]
=
$table
;
...
...
@@ -114,10 +109,6 @@ abstract class Driver extends \yii\base\Object
$this
->
_tables
[
$name
]
=
$table
=
$this
->
loadTableSchema
(
$realName
);
}
if
(
isset
(
$qcDuration
))
{
// re-enable query caching
$db
->
queryCachingDuration
=
$qcDuration
;
}
return
$table
;
}
...
...
@@ -185,7 +176,8 @@ abstract class Driver extends \yii\base\Object
public
function
refresh
(
$tableName
=
null
)
{
$db
=
$this
->
connection
;
if
(
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
/** @var $cache \yii\caching\Cache */
if
(
$db
->
enableSchemaCache
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
if
(
$tableName
===
null
)
{
foreach
(
$this
->
_tables
as
$name
=>
$table
)
{
$cache
->
delete
(
$this
->
getCacheKey
(
$name
));
...
...
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