feat: khởi tạo/huỷ domain Plesk qua job, gửi mail hoá đơn qua queue, đính kèm triển khai
- ProvisionDnsDomainJob/SuspendDnsDomainJob: tạo domain admin lên Plesk, huỷ = suspend (is_created=3) - Khách xem zone DNS được gán ở /dich-vu/domain, quản lý bản ghi A/AAAA/CNAME/TXT/MX/SRV - send-mail hoá đơn đẩy SendInvoiceMailJob, preview + sửa nội dung, ghi mail.order_id - invoice_attachments.type (payment_proof/deployment) - CacheService xoá theo SCAN pattern, Redis không persistent mặc định - Backfill transactions.public_code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
30898ea46f
commit
94614d9cb3
@@ -3,10 +3,11 @@
|
||||
namespace App\Services\Cache;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Cache\RedisStore;
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Str;
|
||||
use stdClass;
|
||||
|
||||
class CacheService implements CacheServiceInterface
|
||||
@@ -66,11 +67,6 @@ class CacheService implements CacheServiceInterface
|
||||
|
||||
public function clearByModule(string $module): void
|
||||
{
|
||||
if ($this->supportsTagging()) {
|
||||
Cache::tags([$module])->flush();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->scanAndDelete($module);
|
||||
}
|
||||
|
||||
@@ -87,32 +83,24 @@ class CacheService implements CacheServiceInterface
|
||||
return Cache::store();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all keys for a module using SCAN (safe for production).
|
||||
*
|
||||
* KEYS is O(N) and blocks Redis; SCAN iterates in batches without blocking.
|
||||
* The pattern matches: {cache_prefix}:{module}:*
|
||||
*/
|
||||
private function scanAndDelete(string $module): void
|
||||
{
|
||||
$redis = Redis::connection('cache');
|
||||
$prefix = config('cache.prefix');
|
||||
$pattern = "{$prefix}:{$module}:*";
|
||||
$cursor = '0';
|
||||
$store = Cache::store()->getStore();
|
||||
if (! $store instanceof RedisStore) {
|
||||
return;
|
||||
}
|
||||
|
||||
$redis = $store->connection();
|
||||
$connectionPrefix = (string) config('database.redis.options.prefix');
|
||||
$pattern = $connectionPrefix . $store->getPrefix() . $module . ':*';
|
||||
$cursor = '0';
|
||||
|
||||
do {
|
||||
$result = $redis->scan($cursor, 'MATCH', $pattern, 'COUNT', 100);
|
||||
|
||||
if ($result === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
[$cursor, $keys] = $result;
|
||||
[$cursor, $keys] = $redis->scan($cursor, ['match' => $pattern, 'count' => 500]) ?: ['0', []];
|
||||
|
||||
foreach ((array) $keys as $key) {
|
||||
$redis->del($key);
|
||||
$redis->del(Str::after($key, $connectionPrefix));
|
||||
}
|
||||
|
||||
} while ((string) $cursor !== '0');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user