forked from RickySu/tagcache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTagcacheObj.php
50 lines (43 loc) · 1.1 KB
/
TagcacheObj.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace RickySu\Tagcache;
class TagcacheObj
{
public $Var;
public $Tags;
public $Timestamp;
public $expire;
public $Chunked = 0;
/**
* @param mixed $Var
* @param array $Tags
* @param TagMemcache $TagMemcache
*/
public function __construct($Var, $Tags, $expire = 0)
{
$this->Var = $Var;
$this->Tags = $Tags;
$this->Timestamp = TagcacheTime::time();
$this->expire = $expire;
}
public function getVar($CacheAdapter)
{
if ($this->expire && ($this->expire < TagcacheTime::time())) {
return false;
}
if (is_array($this->Tags))
foreach ($this->Tags as $Tag) {
$TagTimestamp = $CacheAdapter->getTagUpdateTimestamp($Tag);
if ($TagTimestamp === false) {
return false;
}
if ($TagTimestamp > $this->Timestamp) {
return false;
}
}
return $this->Var;
}
public function getTags()
{
return $this->Tags;
}
}