src/Phossa2/Cache/Extension/StampedeProtection.php
public function stampedeProtect(EventInterface $event)/*# : bool */
    {
        /* @var CachePool $pool */
        $pool = $event->getTarget();
        /* @var CacheItem $item */
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            $left = $item->getExpiration()->getTimestamp() - time();
            if ($left < $this->time_left && rand(1, 1000) <= $this->probability) {
                return $pool->setError(
                    Message::get(Message::CACHE_EXT_STAMPEDE, $item->getKey()),
                    Message::CACHE_EXT_STAMPEDE
                );
            }
        }

        return true;
    }
public function stampedeProtect(EventInterface $event)/*# : bool */
    {
        /* @var CachePool $pool */
        $pool = $event->getTarget();
        /* @var CacheItem $item */
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            $left = $item->getExpiration()->getTimestamp() - time();
            if ($left < $this->time_left && rand(1, 1000) <= $this->probability) {
                return $pool->setError(
                    Message::get(Message::CACHE_EXT_STAMPEDE, $item->getKey()),
                    Message::CACHE_EXT_STAMPEDE
                );
            }
        }

        return true;
    }
public function stampedeProtect ( EventInterface $ event ) /*# : bool */ { /* @var CachePool $pool */ $ pool = $ event -> getTarget ( ) ; /* @var CacheItem $item */ $ item = $ event -> getParam ( 'item' ) ; if ( $ item instanceof CacheItemExtendedInterface ) { $ left = $ item -> getExpiration ( ) -> getTimestamp ( ) - time ( ) ; if ( $ left < $ this -> time_left && rand ( 1 , 1000 ) <= $ this -> probability ) { return $ pool -> setError ( Message :: get ( Message :: CACHE_EXT_STAMPEDE , $ item -> getKey ( ) ) , Message :: CACHE_EXT_STAMPEDE ) ; } } return true ; }
Change hit status if ...

@param  EventInterface $event
@return bool
@access public
Change hit status if ...