expire() public static method

Expires the named value from the cache.
public static expire ( mixed $name, string $match_mode = 'strict' )
$name mixed The name of the cached item or an array of array( string $group, string $name )
$match_mode string (optional) how to match item names ('strict', 'regex', 'glob') (default 'strict')
Esempio n. 1
0
 public function action_admin_moderate_comments($action, Comments $comments, AdminHandler $handler)
 {
     $false_positives = array();
     $false_negatives = array();
     foreach ($comments as $comment) {
         switch ($action) {
             case 'spam':
                 if (($comment->status == Comment::STATUS_APPROVED || $comment->status == Comment::STATUS_UNAPPROVED) && isset($comment->info->defensio_signature)) {
                     $false_negatives[] = $comment->info->defensio_signature;
                 }
                 break;
             case 'approve':
                 if ($comment->status == Comment::STATUS_SPAM && isset($comment->info->defensio_signature)) {
                     $false_positives[] = $comment->info->defensio_signature;
                 }
                 break;
         }
     }
     try {
         if ($false_positives) {
             $this->defensio->report_false_positives(array('signatures' => $false_positives));
             Cache::expire('defensio_stats');
             $count = count($false_positives);
             Session::notice(sprintf(_n('Reported %d false positive to Defensio', 'Reported %d false positives to Defensio', $count, 'defensio'), $count));
         }
         if ($false_negatives) {
             $this->defensio->report_false_negatives(array('signatures' => $false_negatives));
             Cache::expire('defensio_stats');
             $count = count($false_negatives);
             Session::notice(sprintf(_n('Reported %d false negative to Defensio', 'Reported %d false negatives to Defensio', $count, 'defensio'), $count));
         }
     } catch (Exception $e) {
         EventLog::log($e->getMessage(), 'notice', 'comment', 'Defensio');
     }
 }