Repository navigation
Expand file tree
/
Copy pathCache.php
More file actions
71 lines (56 loc) · 1.45 KB
/
Copy pathCache.php
File metadata and controls
71 lines (56 loc) · 1.45 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class EtuDev_PseudoArray_Cache
{
/**
* @var EtuDev_PseudoArray_Cache
*/
static protected $instansce;
/**
* @return EtuDev_PseudoArray_Cache
*/
static public function getInstance()
{
if (!static::$instansce) {
static::$instansce = new EtuDev_PseudoArray_Cache();
}
return static::$instansce;
}
protected $enabled = true;
public function isEnabled()
{
return $this->enabled && EtuDev_Cache_Engine_Fast::getInstance()->isEnabled();
}
public function enable()
{
$this->enabled = true;
}
public function disable()
{
$this->enabled = false;
}
protected $prefix;
protected function getPrefix()
{
if (!$this->prefix) {
$this->prefix = 'psa' . (defined('APPLICATION_HASHKEY') ? APPLICATION_HASHKEY : '');
}
return $this->prefix;
}
protected function completeKey($k)
{
return $this->getPrefix() . $k;
}
public function write($k, $v, $time_to_live = 86400)
{
$key = $this->completeKey($k);
return EtuDev_Cache_Engine_Fast::getInstance()->set($key, $v, $time_to_live);
}
public function get($k)
{
return EtuDev_Cache_Engine_Fast::getInstance()->get($this->completeKey($k));
}
public function deleteAll()
{
return EtuDev_Cache_Engine_Fast::getInstance()->deleteAllPrefix($this->getPrefix());
}
}