public function testExpiredCleanup()
 {
     $this->assertTrue($this->_instance->clean());
     $this->assertTrue($this->_instance->save('BLAH', 'foo', array('TAG1', 'TAG2'), 1));
     $this->assertTrue($this->_instance->save('BLAH', 'bar', array('TAG1', 'TAG3'), 1));
     $this->assertEquals(array('foo', 'bar'), $this->_instance->getIdsMatchingAnyTags(array('TAG1', 'TAG2', 'TAG3')));
     // sleep(2);
     $this->_instance->___expire('foo');
     $this->_instance->___expire('bar');
     $this->_instance->clean(Zend_Cache::CLEANING_MODE_OLD);
     $this->assertEquals(array(), $this->_instance->getIdsMatchingAnyTags(array('TAG1', 'TAG2', 'TAG3')));
     $this->assertEquals(array(), $this->_instance->getTags());
 }
 public function testCleanModeMatchingAnyTags6()
 {
     $tags = array();
     for ($i = 0; $i < self::LUA_MAX_C_STACK * 5; $i++) {
         $tags[] = 'baz' . $i;
     }
     $this->_instance->save('foo', 'foo', $tags);
     $_tags = array(end($tags));
     $this->assertEquals(1, count($this->_instance->getIdsMatchingAnyTags($_tags)));
     $this->_instance->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $_tags);
     $this->assertEquals(0, count($this->_instance->getIdsMatchingAnyTags($_tags)));
 }
 /**
  * This method will catch exceptions on Redis failure.
  * This method will return false when constructor failed.
  *
  * This method will dispatch the event 'jv_cache_save_block' when cache is saved for a html block.
  *
  * {@inheritdoc}
  */
 public function save($data, $id, $tags = array(), $specificLifetime = false)
 {
     $result = false;
     if (in_array($this->getFrontendPrefix() . 'BLOCK_HTML', $tags)) {
         $transportObject = new Varien_Object();
         /** @noinspection PhpUndefinedMethodInspection */
         $transportObject->setTags($tags);
         Mage::dispatchEvent('jv_cache_save_block', array('id' => $id, 'transport' => $transportObject));
         /** @noinspection PhpUndefinedMethodInspection */
         $tags = $transportObject->getTags();
     }
     if ($this->works) {
         try {
             $result = parent::save($data, $id, $tags, $specificLifetime);
         } catch (CredisException $e) {
             $this->processRedisException($e, 'save');
             $result = false;
         } catch (RedisException $e) {
             $this->processRedisException($e, 'save');
             $result = false;
         } catch (Zend_Cache_Exception $e) {
             $this->processRedisException($e, 'save');
             $result = false;
         }
     }
     return $result;
 }