Abstract.php
1.5 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
abstract class Q_Cache_Abstract implements Q_Cache_Interface
{
/**
*
* 域 & 前缀
* @var String
*/
protected $domain = 'qf.domain';
/**
* 接点
*
* @var String
*/
protected $class = 'default';
/**
* Server List
*
* @var Array
*/
protected $servers = array();
/**
* 前缀
* @var string
*/
protected $keyPrefix = '';
/**
* Tag
* @var string
*/
protected $tagName = '';
/**
* Memcached Obj
*
* @var Memcached
*/
protected $_cache;
/**
*
* tag 前缀
* @return String
*/
protected function getTagPrefix($rw_mode = false)
{
if (empty($this->tagName)) {
return '';
}
$key = $this->tagKey($this->tagName);
$_tag_val = $this->_cache->get($key);
if (empty($_tag_val) && $rw_mode == true) {
$_tag_val = md5(microtime() . mt_rand() . uniqid());
$this->_cache->set($key, $_tag_val, 0);
}
return empty($_tag_val) ? '' : $_tag_val . '.';
}
/**
*
* Tag key
* @param String $tagName
* @return String
*/
protected function tagKey($tagName)
{
return 'cache.tag.' . md5($tagName);
}
/**
* 初始化数据
*/
protected function _unset()
{
$this->tagName = '';
$this->domain = 'qf.domain';
$this->class = 'default';
$this->keyPrefix = '';
}
}