-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Turbo124\Beacon\Commands; | ||
|
||
use App; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Cache; | ||
use Turbo124\Beacon\Jobs\BatchMetrics; | ||
|
||
|
||
class PurgeAnalytics extends Command | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $name = 'beacon:purge'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = 'Purging any analytics in the cache'; | ||
|
||
protected $log = ''; | ||
|
||
public function handle() | ||
{ | ||
$this->logMessage('Purging Data'); | ||
|
||
$metric_types = ['counter', 'gauge', 'multi_metric', 'mixed_metric']; | ||
|
||
foreach($metric_types as $type) | ||
{ | ||
|
||
$this->logMessage("purging {$type}"); | ||
|
||
Cache::forget(config('beacon.cache_key') . '_' . $type); | ||
} | ||
|
||
$this->logMessage('Finished Purging Data'); | ||
|
||
|
||
} | ||
|
||
private function logMessage($str) | ||
{ | ||
$str = date('Y-m-d h:i:s') . ' ' . $str; | ||
$this->info($str); | ||
$this->log .= $str . " \n"; | ||
} | ||
} |