コード例 #1
0
 /**
  * Optimize by factor on a success _RESULT_
  *
  * @param  PostEvent $event
  * @return void
  */
 public function optimizeByFactor(PostEvent $event)
 {
     $storage = $event->getStorage();
     if (!$storage instanceof OptimizableInterface) {
         return;
     }
     $factor = $this->getOptions()->getOptimizingFactor();
     if ($factor && mt_rand(1, $factor) == 1) {
         $storage->optimize();
     }
 }
コード例 #2
0
 /**
  * Clear expired items by factor after writing new item(s)
  *
  * @param  PostEvent $event
  * @return void
  */
 public function clearExpiredByFactor(PostEvent $event)
 {
     $storage = $event->getStorage();
     if (!$storage instanceof ClearExpiredInterface) {
         return;
     }
     $factor = $this->getOptions()->getClearingFactor();
     if ($factor && mt_rand(1, $factor) == 1) {
         $storage->clearExpired();
     }
 }
コード例 #3
0
ファイル: ClearByFactor.php プロジェクト: nevvermind/zf2
 /**
  * Clear storage by factor on a success _RESULT_
  *
  * @param  PostEvent $event
  * @return void
  */
 public function clearByFactor(PostEvent $event)
 {
     $options = $this->getOptions();
     $factor = $options->getClearingFactor();
     if ($factor && $event->getResult() && mt_rand(1, $factor) == 1) {
         $params = $event->getParams();
         if ($options->getClearByNamespace()) {
             $event->getStorage()->clearByNamespace(Adapter::MATCH_EXPIRED, $params['options']);
         } else {
             $event->getStorage()->clear(Adapter::MATCH_EXPIRED, $params['options']);
         }
     }
 }
コード例 #4
0
ファイル: OptimizeByFactor.php プロジェクト: nevvermind/zf2
 /**
  * Optimize by factor on a success _RESULT_
  *
  * @param  PostEvent $event
  * @return void
  */
 public function optimizeByFactor(PostEvent $event)
 {
     $factor = $this->getOptions()->getOptimizingFactor();
     if ($factor && $event->getResult() && mt_rand(1, $factor) == 1) {
         $params = $event->getParams();
         $event->getStorage()->optimize($params['options']);
     }
 }