public function distributeExpire(EventInterface $event)/*# : bool */
    {
        $dist = $this->distribution;
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            // expire ttl
            $ttl = $item->getExpiration()->getTimestamp() - time();

            // percentage
            $percent = (rand(0, $dist * 2) - $dist) * 0.001;

            // new expire ttl
            $new_ttl = (int) round($ttl + $ttl * $percent);
            $item->expiresAfter($new_ttl);
        }

        return true;
    }
public function distributeExpire(EventInterface $event)/*# : bool */
    {
        $dist = $this->distribution;
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            // expire ttl
            $ttl = $item->getExpiration()->getTimestamp() - time();

            // percentage
            $percent = (rand(0, $dist * 2) - $dist) * 0.001;

            // new expire ttl
            $new_ttl = (int) round($ttl + $ttl * $percent);
            $item->expiresAfter($new_ttl);
        }

        return true;
    }
public function distributeExpire ( EventInterface $ event ) /*# : bool */ { $ dist = $ this -> distribution ; $ item = $ event -> getParam ( 'item' ) ; if ( $ item instanceof CacheItemExtendedInterface ) { // expire ttl $ ttl = $ item -> getExpiration ( ) -> getTimestamp ( ) - time ( ) ; // percentage $ percent = ( rand ( 0 , $ dist * 2 ) - $ dist ) * 0.001 ; // new expire ttl $ new_ttl = ( int ) round ( $ ttl + $ ttl * $ percent ) ; $ item -> expiresAfter ( $ new_ttl ) ; } return true ; }
Evenly distribute the expiration time

@param  EventInterface $event
@return bool
@access public
Evenly distribute the expiration time