public function garbageCollection($scope = null, $maximumLifetime = null, $force = false)
    {
        // Default result
        $result = 0;

        // Get our active scope if no special one passed
        if ($scope === null) {
            $scope = $this->getScope();
        }

        // The maximum lifetime for the entry in seconds
        if ($maximumLifetime === null) {
            $maximumLifetime = $this->getGcMaximumLifetime();
        }

        // Start the randomizer ...
        srand(microtime(true));

        // Force || Time and probability based
        if (
            ($force) ||                                                                // Forced run
            (
                self::$gcLastRunTimestamp !== null &&                                  // Must be run and ...
                self::$gcLastRunTimestamp < (time() + $this->getGcProbabilityTime())   // ... more than 30 min. before
            ) ||
            (rand(1, 100) <= $this->gcProbability)                                     // or randomizer hit?
        ) {
            $result                   = $this->getContainer()->garbageCollection($scope, $maximumLifetime);
            self::$gcLastRunTimestamp = time();
        }

        return $result;
    }
public function garbageCollection($scope = null, $maximumLifetime = null, $force = false)
    {
        // Default result
        $result = 0;

        // Get our active scope if no special one passed
        if ($scope === null) {
            $scope = $this->getScope();
        }

        // The maximum lifetime for the entry in seconds
        if ($maximumLifetime === null) {
            $maximumLifetime = $this->getGcMaximumLifetime();
        }

        // Start the randomizer ...
        srand(microtime(true));

        // Force || Time and probability based
        if (
            ($force) ||                                                                // Forced run
            (
                self::$gcLastRunTimestamp !== null &&                                  // Must be run and ...
                self::$gcLastRunTimestamp < (time() + $this->getGcProbabilityTime())   // ... more than 30 min. before
            ) ||
            (rand(1, 100) <= $this->gcProbability)                                     // or randomizer hit?
        ) {
            $result                   = $this->getContainer()->garbageCollection($scope, $maximumLifetime);
            self::$gcLastRunTimestamp = time();
        }

        return $result;
    }
public function garbageCollection ( $ scope = null , $ maximumLifetime = null , $ force = false ) { // Default result $ result = 0 ; // Get our active scope if no special one passed if ( $ scope === null ) { $ scope = $ this -> getScope ( ) ; } // The maximum lifetime for the entry in seconds if ( $ maximumLifetime === null ) { $ maximumLifetime = $ this -> getGcMaximumLifetime ( ) ; } // Start the randomizer ... srand ( microtime ( true ) ) ; // Force || Time and probability based if ( ( $ force ) || // Forced run ( self :: $ gcLastRunTimestamp !== null && // Must be run and ... self :: $ gcLastRunTimestamp < ( time ( ) + $ this -> getGcProbabilityTime ( ) ) // ... more than 30 min. before ) || ( rand ( 1 , 100 ) <= $ this -> gcProbability ) // or randomizer hit? ) { $ result = $ this -> getContainer ( ) -> garbageCollection ( $ scope , $ maximumLifetime ) ; self :: $ gcLastRunTimestamp = time ( ) ; } return $ result ; }
Calls the garbage-collector of the cache-container.

- is forced ($force = true)
- there was a run before and this run is older = gcProbabilityTime

@param string $scope           The scope to look for elements in
@param int    $maximumLifetime The maximum lifetime of an element
@param bool   $force           TRUE to force a garbage collection run, otherwise FALSE (default) to check

@author Benjamin Carl <opensource@clickalicious.de>

@return int The number of elements collected in gc run
Calls the garbage - collector of the cache - container .