MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
MemcacheCache.php
Ir para a documentação deste ficheiro.
1<?php
2/*
3 * $Id$
4 *
5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 *
17 * This software consists of voluntary contributions made by many individuals
18 * and is licensed under the LGPL. For more information, see
19 * <http://www.doctrine-project.org>.
20 */
21
22namespace Doctrine\Common\Cache;
23
24use \Memcache;
25
40{
44 private $_memcache;
45
51 public function setMemcache(Memcache $memcache)
52 {
53 $this->_memcache = $memcache;
54 }
55
61 public function getMemcache()
62 {
63 return $this->_memcache;
64 }
65
69 public function getIds()
70 {
71 $keys = array();
72 $allSlabs = $this->_memcache->getExtendedStats('slabs');
73
74 foreach ($allSlabs as $server => $slabs) {
75 if (is_array($slabs)) {
76 foreach (array_keys($slabs) as $slabId) {
77 $dump = $this->_memcache->getExtendedStats('cachedump', (int) $slabId);
78
79 if ($dump) {
80 foreach ($dump as $entries) {
81 if ($entries) {
82 $keys = array_merge($keys, array_keys($entries));
83 }
84 }
85 }
86 }
87 }
88 }
89 return $keys;
90 }
91
95 protected function _doFetch($id)
96 {
97 return $this->_memcache->get($id);
98 }
99
103 protected function _doContains($id)
104 {
105 return (bool) $this->_memcache->get($id);
106 }
107
111 protected function _doSave($id, $data, $lifeTime = 0)
112 {
113 return $this->_memcache->set($id, $data, 0, (int) $lifeTime);
114 }
115
119 protected function _doDelete($id)
120 {
121 return $this->_memcache->delete($id);
122 }
123}
_doSave($id, $data, $lifeTime=0)
$id
Definição base.php:5