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
b181bc1c
Commit
b181bc1c
authored
Jan 18, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated cache key usage.
parent
11d374a8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
Command.php
framework/db/Command.php
+1
-1
Schema.php
framework/db/Schema.php
+7
-5
No files found.
framework/db/Command.php
View file @
b181bc1c
...
...
@@ -418,7 +418,7 @@ class Command extends \yii\base\Component
}
if
(
isset
(
$cache
))
{
$cacheKey
=
__CLASS__
.
"/
{
$db
->
dsn
}
/
{
$db
->
username
}
/
$sql
/
$paramLog
"
;
$cacheKey
=
$cache
->
buildKey
(
__CLASS__
,
$db
->
dsn
,
$db
->
username
,
$sql
,
$paramLog
)
;
if
((
$result
=
$cache
->
get
(
$cacheKey
))
!==
false
)
{
\Yii
::
trace
(
'Query result found in cache'
,
__CLASS__
);
return
$result
;
...
...
framework/db/Schema.php
View file @
b181bc1c
...
...
@@ -11,6 +11,7 @@ namespace yii\db;
use
yii\base\NotSupportedException
;
use
yii\base\InvalidCallException
;
use
yii\caching\Cache
;
/**
* Schema is the base class for concrete DBMS-specific schema classes.
...
...
@@ -85,9 +86,9 @@ abstract class Schema extends \yii\base\Object
$db
=
$this
->
db
;
$realName
=
$this
->
getRealTableName
(
$name
);
/** @var $cache
\yii\caching\
Cache */
/** @var $cache Cache */
if
(
$db
->
enableSchemaCache
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
&&
!
in_array
(
$name
,
$db
->
schemaCacheExclude
,
true
))
{
$key
=
$this
->
getCacheKey
(
$name
);
$key
=
$this
->
getCacheKey
(
$
cache
,
$
name
);
if
(
$refresh
||
(
$table
=
$cache
->
get
(
$key
))
===
false
)
{
$table
=
$this
->
loadTableSchema
(
$realName
);
if
(
$table
!==
null
)
{
...
...
@@ -104,12 +105,13 @@ abstract class Schema extends \yii\base\Object
/**
* Returns the cache key for the specified table name.
* @param Cache $cache the cache component
* @param string $name the table name
* @return string the cache key
*/
public
function
getCacheKey
(
$name
)
public
function
getCacheKey
(
$
cache
,
$
name
)
{
return
__CLASS__
.
"/
{
$this
->
db
->
dsn
}
/
{
$this
->
db
->
username
}
/
{
$name
}
"
;
return
$cache
->
buildKey
(
__CLASS__
,
$this
->
db
->
dsn
,
$this
->
db
->
username
,
$name
)
;
}
/**
...
...
@@ -171,7 +173,7 @@ abstract class Schema extends \yii\base\Object
/** @var $cache \yii\caching\Cache */
if
(
$this
->
db
->
enableSchemaCache
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$this
->
db
->
schemaCacheID
))
!==
null
)
{
foreach
(
$this
->
_tables
as
$name
=>
$table
)
{
$cache
->
delete
(
$this
->
getCacheKey
(
$name
));
$cache
->
delete
(
$this
->
getCacheKey
(
$
cache
,
$
name
));
}
}
$this
->
_tableNames
=
array
();
...
...
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