Prado\Caching\TDbCache::flushCacheExpired PHP Method

flushCacheExpired() public method

Flush expired values from cache depending on {@link setFlushInterval FlushInterval}
Since: 3.1.5
public flushCacheExpired ( $force = false ) : void
return void
    public function flushCacheExpired($force = false)
    {
        $interval = $this->getFlushInterval();
        if (!$force && $interval === 0) {
            return;
        }
        $key = 'TDbCache:' . $this->_cacheTable . ':flushed';
        $now = time();
        $next = $interval + (int) $this->getApplication()->getGlobalState($key, 0);
        if ($force || $next <= $now) {
            if (!$this->_cacheInitialized) {
                $this->initializeCache();
            }
            Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ') . $this->id . ', ' . $this->_cacheTable, '\\Prado\\Caching\\TDbCache');
            $sql = 'DELETE FROM ' . $this->_cacheTable . ' WHERE expire<>0 AND expire<' . $now;
            $this->getDbConnection()->createCommand($sql)->execute();
            $this->getApplication()->setGlobalState($key, $now);
        }
    }