-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTags.php
More file actions
37 lines (31 loc) · 854 Bytes
/
Tags.php
File metadata and controls
37 lines (31 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class Tags implements ICacheDependency {
protected $timestamp;
protected $tags;
/**
* В качестве параметров передается список тегов
*
* @params tag1, tag2, ..., tagN
*/
function __construct() {
$this->tags = func_get_args();
}
/**
* Evaluates the dependency by generating and saving the data related with dependency.
* This method is invoked by cache before writing data into it.
*/
public function evaluateDependency() {
$this->timestamp = time();
}
/**
* @return boolean whether the dependency has changed.
*/
public function getHasChanged() {
$tags = array_map(function($i) { return TaggingBehavior::PREFIX.$i; }, $this->tags);
$values = Yii::app()->cache->mget($tags);
foreach ($values as $value) {
if ((integer)$value > $this->timestamp) { return true; }
}
return false;
}
}