Files
shopPRO/autoload/Domain/Cache/CacheRepository.php
Jacek Pyziak 431add234c ver. 0.283: Legacy class cleanup — S, Html, Email, Image, Log, Mobile_Detect → Shared namespace
- Migrate class.S → Shared\Helpers\Helpers (140+ files), remove 12 unused methods
- Migrate class.Html → Shared\Html\Html
- Migrate class.Email → Shared\Email\Email
- Migrate class.Image → Shared\Image\ImageManipulator
- Delete class.Log (unused), class.Mobile_Detect (outdated UA detection)
- Remove grid library loading from admin (index.php, ajax.php)
- Replace gridEdit usage in 10 admin templates with grid-edit-replacement.php
- Fix grid-edit-replacement.php AJAX to send values as JSON (grid.js compat)
- Remove mobile layout conditionals (m_html/m_css/m_js) from Site + LayoutsRepository
- Remove \Log::save_log() calls from OrderAdminService, ShopOrder, Order

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 23:06:06 +01:00

54 lines
1.5 KiB
PHP

<?php
namespace Domain\Cache;
/**
* Repozytorium zarządzania cache (katalogi + Redis)
*
* Wyodrębniona logika czyszczenia cache z wstrzykiwanymi zależnościami.
* Obecnie nie używane przez SettingsController (cache czyszczony bezpośrednio).
* Przygotowane na przyszłe użycie w innych kontrolerach.
*/
class CacheRepository
{
private $redisConnection;
private $basePath;
/**
* @param \Shared\Cache\RedisConnection $redisConnection Połączenie z Redis (nullable)
* @param string $basePath Ścieżka bazowa do katalogów cache
*/
public function __construct(
?\Shared\Cache\RedisConnection $redisConnection = null,
string $basePath = '../'
) {
$this->redisConnection = $redisConnection;
$this->basePath = $basePath;
}
/**
* Czyszczenie całego cache (katalogi + Redis)
*
* @return array ['success' => bool, 'message' => string]
*/
public function clearCache(): array
{
\Shared\Helpers\Helpers::delete_dir( $this->basePath . 'temp/' );
\Shared\Helpers\Helpers::delete_dir( $this->basePath . 'thumbs/' );
$redisCleared = false;
if ( $this->redisConnection ) {
$redis = $this->redisConnection->getConnection();
if ( $redis ) {
$redis->flushAll();
$redisCleared = true;
}
}
return [
'success' => true,
'message' => 'Cache został wyczyszczony.',
'redisCleared' => $redisCleared
];
}
}