MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
AbstractCache.php
Ir para a documentação deste ficheiro.
1
<?php
2
/*
3
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
*
15
* This software consists of voluntary contributions made by many individuals
16
* and is licensed under the LGPL. For more information, see
17
* <http://www.doctrine-project.org>.
18
*/
19
20
namespace
Doctrine\Common\Cache
;
21
31
abstract
class
AbstractCache
implements
Cache
32
{
34
private
$_cacheIdsIndexId =
'doctrine_cache_ids'
;
35
37
private
$_namespace =
null
;
38
45
public
function
setNamespace
($namespace)
46
{
47
$this->_namespace = $namespace;
48
}
49
53
public
function
fetch
(
$id
)
54
{
55
return
$this->
_doFetch
($this->_getNamespacedId(
$id
));
56
}
57
61
public
function
contains
(
$id
)
62
{
63
return
$this->
_doContains
($this->_getNamespacedId(
$id
));
64
}
65
69
public
function
save
(
$id
, $data, $lifeTime = 0)
70
{
71
return
$this->
_doSave
($this->_getNamespacedId(
$id
), $data, $lifeTime);
72
}
73
77
public
function
delete
(
$id
)
78
{
79
$id
= $this->_getNamespacedId(
$id
);
80
81
if
(strpos(
$id
,
'*'
) !==
false
) {
82
return
$this->
deleteByRegex
(
'/'
. str_replace(
'*'
,
'.*'
,
$id
) .
'/'
);
83
}
84
85
return
$this->
_doDelete
(
$id
);
86
}
87
93
public
function
deleteAll
()
94
{
95
$ids = $this->
getIds
();
96
97
foreach
($ids as
$id
) {
98
$this->
delete
(
$id
);
99
}
100
101
return
$ids;
102
}
103
110
public
function
deleteByRegex
($regex)
111
{
112
$deleted = array();
113
114
$ids = $this->
getIds
();
115
116
foreach
($ids as
$id
) {
117
if
(preg_match($regex,
$id
)) {
118
$this->
delete
(
$id
);
119
$deleted[] =
$id
;
120
}
121
}
122
123
return
$deleted;
124
}
125
132
public
function
deleteByPrefix
($prefix)
133
{
134
$deleted = array();
135
136
$prefix = $this->_getNamespacedId($prefix);
137
$ids = $this->
getIds
();
138
139
foreach
($ids as
$id
) {
140
if
(strpos(
$id
, $prefix) === 0) {
141
$this->
delete
(
$id
);
142
$deleted[] =
$id
;
143
}
144
}
145
146
return
$deleted;
147
}
148
155
public
function
deleteBySuffix
($suffix)
156
{
157
$deleted = array();
158
159
$ids = $this->
getIds
();
160
161
foreach
($ids as
$id
) {
162
if
(substr(
$id
, -1 * strlen($suffix)) === $suffix) {
163
$this->
delete
(
$id
);
164
$deleted[] =
$id
;
165
}
166
}
167
168
return
$deleted;
169
}
170
177
private
function
_getNamespacedId(
$id
)
178
{
179
if
( ! $this->_namespace || strpos(
$id
, $this->_namespace) === 0) {
180
return
$id
;
181
}
else
{
182
return
$this->_namespace .
$id
;
183
}
184
}
185
192
abstract
protected
function
_doFetch
(
$id
);
193
200
abstract
protected
function
_doContains
(
$id
);
201
210
abstract
protected
function
_doSave
(
$id
, $data, $lifeTime =
false
);
211
218
abstract
protected
function
_doDelete
(
$id
);
219
225
abstract
public
function
getIds
();
226
}
Doctrine\Common\Cache\AbstractCache
Definição
AbstractCache.php:32
Doctrine\Common\Cache\AbstractCache\_doContains
_doContains($id)
Doctrine\Common\Cache\AbstractCache\save
save($id, $data, $lifeTime=0)
Definição
AbstractCache.php:69
Doctrine\Common\Cache\AbstractCache\deleteBySuffix
deleteBySuffix($suffix)
Definição
AbstractCache.php:155
Doctrine\Common\Cache\AbstractCache\contains
contains($id)
Definição
AbstractCache.php:61
Doctrine\Common\Cache\AbstractCache\_doFetch
_doFetch($id)
Doctrine\Common\Cache\AbstractCache\setNamespace
setNamespace($namespace)
Definição
AbstractCache.php:45
Doctrine\Common\Cache\AbstractCache\deleteByRegex
deleteByRegex($regex)
Definição
AbstractCache.php:110
Doctrine\Common\Cache\AbstractCache\deleteByPrefix
deleteByPrefix($prefix)
Definição
AbstractCache.php:132
Doctrine\Common\Cache\AbstractCache\_doSave
_doSave($id, $data, $lifeTime=false)
Doctrine\Common\Cache\AbstractCache\deleteAll
deleteAll()
Definição
AbstractCache.php:93
Doctrine\Common\Cache\AbstractCache\fetch
fetch($id)
Definição
AbstractCache.php:53
Doctrine\Common\Cache\AbstractCache\_doDelete
_doDelete($id)
Doctrine\Common\Cache\AbstractCache\getIds
getIds()
Doctrine\Common\Cache\Cache
Definição
Cache.php:37
Doctrine\Common\Cache
Definição
AbstractCache.php:20
$id
$id
Definição
base.php:5
classes
extensions
doctrine-dbal
Doctrine
Common
Cache
AbstractCache.php
Gerado por
1.10.0