123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
-
-
- namespace Doctrine\Common\Cache;
-
- use \Memcache;
-
-
- class MemcacheCache extends AbstractCache
- {
-
-
- private $_memcache;
-
-
-
- public function setMemcache(Memcache $memcache)
- {
- $this->_memcache = $memcache;
- }
-
-
-
- public function getMemcache()
- {
- return $this->_memcache;
- }
-
-
-
- public function getIds()
- {
- $keys = array();
- $allSlabs = $this->_memcache->getExtendedStats('slabs');
-
- foreach ($allSlabs as $server => $slabs) {
- if (is_array($slabs)) {
- foreach (array_keys($slabs) as $slabId) {
- $dump = $this->_memcache->getExtendedStats('cachedump', (int) $slabId);
-
- if ($dump) {
- foreach ($dump as $entries) {
- if ($entries) {
- $keys = array_merge($keys, array_keys($entries));
- }
- }
- }
- }
- }
- }
- return $keys;
- }
-
-
-
- protected function _doFetch($id)
- {
- return $this->_memcache->get($id);
- }
-
-
-
- protected function _doContains($id)
- {
- return (bool) $this->_memcache->get($id);
- }
-
-
-
- protected function _doSave($id, $data, $lifeTime = 0)
- {
- return $this->_memcache->set($id, $data, 0, (int) $lifeTime);
- }
-
-
-
- protected function _doDelete($id)
- {
- return $this->_memcache->delete($id);
- }
- }
|