3 namespace Doctrine\Tests\Common\Cache;
5 use Doctrine\Common\Cache\MemcacheCache;
7 class MemcacheCacheTest extends CacheTest
11 public function setUp()
13 if (extension_loaded('memcache')) {
14 $this->_memcache = new \Memcache;
15 $ok = @$this->_memcache->connect('localhost', 11211);
17 $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
20 $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
24 public function testNoExpire() {
25 $cache = $this->_getCacheDriver();
26 $cache->save('noexpire', 'value', 0);
28 $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire');
31 public function testLongLifetime()
33 $cache = $this->_getCacheDriver();
34 $cache->save('key', 'value', 30 * 24 * 3600 + 1);
35 $this->assertTrue($cache->contains('key'), 'Memcache provider should support TTL > 30 days');
38 protected function _getCacheDriver()
40 $driver = new MemcacheCache();
41 $driver->setMemcache($this->_memcache);