| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | class Red_Flusher { |
| 4 | 4 | const DELETE_HOOK = 'redirection_log_delete'; |
| 5 | 5 | const DELETE_FREQ = 'daily'; |
| 6 | - const DELETE_MAX = 3000; | |
| 7 | - const DELETE_KEEP_ON = 10; // 10 minutes | |
| 6 | + const DELETE_MAX = 1000; | |
| 7 | + const DELETE_KEEP_ON = 15; // 15 minutes | |
| 8 | 8 | |
| 9 | 9 | public function flush() { |
| 10 | 10 | $options = red_get_options(); |
| 11 | 11 | |
| @@ -26,15 +26,14 @@ | ||
| 26 | 26 | |
| 27 | 27 | private function optimize_logs() { |
| 28 | 28 | global $wpdb; |
| 29 | 29 | |
| 30 | - $rand = wp_rand( 1, 5000 ); | |
| 30 | + $rand = mt_rand( 1, 5000 ); | |
| 31 | 31 | |
| 32 | - if ( $rand === 11 ) { | |
| 32 | + if ( $rand === 11 ) | |
| 33 | 33 | $wpdb->query( "OPTIMIZE TABLE {$wpdb->prefix}redirection_logs" ); |
| 34 | - } elseif ( $rand === 12 ) { | |
| 34 | + elseif ( $rand === 12 ) | |
| 35 | 35 | $wpdb->query( "OPTIMIZE TABLE {$wpdb->prefix}redirection_404" ); |
| 36 | - } | |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | 38 | private function expire_logs( $table, $expiry_time ) { |
| 40 | 39 | global $wpdb; |
| @@ -57,9 +56,10 @@ | ||
| 57 | 56 | if ( $options['expire_redirect'] > 0 || $options['expire_404'] > 0 ) { |
| 58 | 57 | if ( ! wp_next_scheduled( self::DELETE_HOOK ) ) { |
| 59 | 58 | wp_schedule_event( time(), self::DELETE_FREQ, self::DELETE_HOOK ); |
| 60 | 59 | } |
| 61 | - } else { | |
| 60 | + } | |
| 61 | + else { | |
| 62 | 62 | Red_Flusher::clear(); |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |