/** * Internal method to check if the given cache supports tags * * @return false|string */ protected static function _getTagSupportForCache() { if (!self::$_cache instanceof CacheAdapter) { self::$_cacheTags = false; return false; } $capabilities = self::$_cache->getCapabilities(); if (!$capabilities->getTagging()) { self::$_cacheTags = false; return false; } self::$_cacheTags = true; return true; }
public function testFindExpired() { $capabilities = $this->_storage->getCapabilities(); if (!$capabilities->getIterable()) { $this->markTestSkipped("Find isn't supported by this adapter"); } $this->_options->setTtl($capabilities->getTtlPrecision()); $this->assertTrue($this->_storage->setItem('key1', 'value1')); $this->assertTrue($this->_storage->setItem('key2', 'value2')); // wait until first 2 items expired usleep($capabilities->getTtlPrecision() * 2000000); $this->assertTrue($this->_storage->setItem('key3', 'value3')); $this->assertTrue($this->_storage->setItem('key4', 'value4')); $this->assertTrue($this->_storage->find(AdapterInterface::MATCH_EXPIRED)); if ($capabilities->getExpiredRead() && !$capabilities->getUseRequestTime()) { $expectedItems = array( 'key1' => 'value1', 'key2' => 'value2' ); } else { $expectedItems = array(); } $actualItems = array(); while (($item = $this->_storage->fetch()) !== false) { // check $item $this->assertArrayHasKey('key', $item); $this->assertArrayHasKey('value', $item); $this->assertEquals(2, count($item)); $actualItems[ $item['key'] ] = $item['value']; } ksort($actualItems); $this->assertEquals($expectedItems, $actualItems); }