コード例 #1
0
 public function disableCache()
 {
     $connector = $this->getConnector();
     if (!$connector instanceof CacheToggle) {
         throw CacheUnavailableException::modify();
     }
     $connector->disableCache();
 }
コード例 #2
0
ファイル: Porter.php プロジェクト: ScriptFUSION/Porter
 private function applyCacheAdvice(Provider $provider, CacheAdvice $cacheAdvice)
 {
     try {
         if (!$provider instanceof CacheToggle) {
             throw CacheUnavailableException::modify();
         }
         switch ("{$cacheAdvice}") {
             case CacheAdvice::MUST_CACHE:
             case CacheAdvice::SHOULD_CACHE:
                 $provider->enableCache();
                 break;
             case CacheAdvice::MUST_NOT_CACHE:
             case CacheAdvice::SHOULD_NOT_CACHE:
                 $provider->disableCache();
         }
     } catch (CacheUnavailableException $exception) {
         if ($cacheAdvice === CacheAdvice::MUST_NOT_CACHE() || $cacheAdvice === CacheAdvice::MUST_CACHE()) {
             throw $exception;
         }
     }
 }