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
00df1e88
Commit
00df1e88
authored
Jun 12, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added GroupDependency.
parent
b06d7a86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
GroupDependency.php
framework/yii/caching/GroupDependency.php
+72
-0
No files found.
framework/yii/caching/GroupDependency.php
0 → 100644
View file @
00df1e88
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\caching
;
/**
* GroupDependency marks a cached data item with a group name.
*
* You may invalidate the cached data items with the same group name all at once
* by calling [[invalidate()]].
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
GroupDependency
extends
Dependency
{
/**
* @var string the group name
*/
public
$group
;
/**
* Constructor.
* @param string $group the group name
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public
function
__construct
(
$group
,
$config
=
array
())
{
$this
->
group
=
$group
;
parent
::
__construct
(
$config
);
}
/**
* Generates the data needed to determine if dependency has been changed.
* This method does nothing in this class.
* @param Cache $cache the cache component that is currently evaluating this dependency
* @return mixed the data needed to determine if dependency has been changed.
*/
protected
function
generateDependencyData
(
$cache
)
{
if
(
$cache
->
get
(
array
(
__CLASS__
,
$this
->
group
))
===
false
)
{
// If the cutoff timestamp is not initialized or is swapped out of the cache, we need to set it.
$this
->
invalidate
(
$cache
,
array
(
__CLASS__
,
$this
->
group
));
}
return
microtime
(
true
);
}
/**
* Performs the actual dependency checking.
* @param Cache $cache the cache component that is currently evaluating this dependency
* @return boolean whether the dependency is changed or not.
*/
public
function
getHasChanged
(
$cache
)
{
$time
=
$cache
->
get
(
array
(
__CLASS__
,
$this
->
group
));
return
$time
===
false
||
$time
>
$this
->
data
;
}
/**
* Invalidates all of the cached data items that have the same [[group]].
* @param Cache $cache the cache component that caches the data items
* @param string $group the group name
*/
public
static
function
invalidate
(
$cache
,
$group
)
{
$cache
->
set
(
array
(
__CLASS__
,
$group
),
microtime
(
true
));
}
}
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