Докинул к 719eb1403f
This commit is contained in:
15
app/Services/Cache/CacheInvalidator.php
Normal file
15
app/Services/Cache/CacheInvalidator.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cache;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class CacheInvalidator
|
||||
{
|
||||
public function forget(array $keys): void
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
Cache::forget($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Services/Cache/CacheKeyBuilder.php
Normal file
17
app/Services/Cache/CacheKeyBuilder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cache;
|
||||
|
||||
class CacheKeyBuilder
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $version = 'v1'
|
||||
) {}
|
||||
|
||||
public function make(string $key, array $parts = []): string
|
||||
{
|
||||
$suffix = empty($parts) ? '' : ':' . implode(':', array_map(static fn ($part) => (string) $part, $parts));
|
||||
|
||||
return "{$this->version}:{$key}{$suffix}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user