isHit() public method

public isHit ( )
Beispiel #1
0
 public function testHit()
 {
     $item = new CacheItem('test_key');
     $this->assertFalse($item->isHit());
     $item->set('foobar');
     $this->assertTrue($item->isHit());
     $item->set(null);
     $this->assertTrue($item->isHit());
     $item->expiresAfter(5);
     $this->assertTrue($item->isHit());
     $item->expiresAfter(-1);
     $this->assertFalse($item->isHit());
 }
 public function testHit()
 {
     $item = new CacheItem('test_key', true, 'value');
     $this->assertTrue($item->isHit());
     $item = new CacheItem('test_key', false, 'value');
     $this->assertFalse($item->isHit());
     $closure = function () {
         return [true, 'value'];
     };
     $item = new CacheItem('test_key', $closure);
     $this->assertTrue($item->isHit());
     $closure = function () {
         return [false, null];
     };
     $item = new CacheItem('test_key', $closure);
     $this->assertFalse($item->isHit());
 }
 /**
  * @param CacheItem|TaggableItemInterface $item
  * @return mixed
  */
 protected function decodeItem($item)
 {
     if ($item->isHit()) {
         return $item->get();
     }
     return null;
 }