Laravel 11, Vuexy Admin 10.3, by admin@koneko.mx
This commit is contained in:
64
modules/Admin/App/Livewire/Cache/RedisStats.php
Normal file
64
modules/Admin/App/Livewire/Cache/RedisStats.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\App\Livewire\Cache;
|
||||
|
||||
use Livewire\Component;
|
||||
use Modules\Admin\App\Services\CacheManagerService;
|
||||
|
||||
class RedisStats extends Component
|
||||
{
|
||||
private $driver = 'redis';
|
||||
private $targetNotify = "#redis-stats-card .notification-container";
|
||||
|
||||
public $redisStats = [];
|
||||
|
||||
protected $listeners = ['reloadRedisStatsEvent' => 'reloadCacheStats'];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->reloadCacheStats(false);
|
||||
}
|
||||
|
||||
public function reloadCacheStats($notify = true)
|
||||
{
|
||||
$cacheManagerService = new CacheManagerService($this->driver);
|
||||
|
||||
$redisStats = $cacheManagerService->getRedisStats();
|
||||
|
||||
$this->redisStats = $redisStats['info'];
|
||||
|
||||
if ($notify) {
|
||||
$this->dispatch(
|
||||
'notification',
|
||||
target: $this->targetNotify,
|
||||
type: $redisStats['status'],
|
||||
message: $redisStats['message']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearCache()
|
||||
{
|
||||
$cacheManagerService = new CacheManagerService($this->driver);
|
||||
|
||||
$message = $cacheManagerService->clearCache();
|
||||
|
||||
$this->reloadCacheStats(false);
|
||||
|
||||
$this->dispatch(
|
||||
'notification',
|
||||
target: $this->targetNotify,
|
||||
type: $message['status'],
|
||||
message: $message['message'],
|
||||
);
|
||||
|
||||
$this->dispatch('reloadCacheStatsEvent', notify: false);
|
||||
$this->dispatch('reloadSessionStatsEvent', notify: false);
|
||||
$this->dispatch('reloadCacheFunctionsStatsEvent', notify: false);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('admin::livewire.cache.redis-stats');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user