Add Redis cache for Meilisearch search results and admin dashboard stats
- Configure Redis DB 2 as Symfony cache adapter - Cache Meilisearch search results for 5 minutes (invalidated on writes) - Cache admin dashboard stats for 10 minutes - Add invalidateSearchCache() called after each Meilisearch write - Update tests to support cache mock injection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Service\MeilisearchService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
@@ -14,17 +16,21 @@ class MeilisearchServiceTest extends TestCase
|
||||
{
|
||||
private HttpClientInterface $httpClient;
|
||||
private MessageBusInterface $bus;
|
||||
private CacheInterface $cache;
|
||||
private MeilisearchService $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->httpClient = $this->createMock(HttpClientInterface::class);
|
||||
$this->bus = $this->createMock(MessageBusInterface::class);
|
||||
$this->cache = $this->createMock(CacheInterface::class);
|
||||
$this->cache->method('get')->willReturnCallback(fn (string $key, callable $callback) => $callback($this->createMock(ItemInterface::class)));
|
||||
$this->service = new MeilisearchService(
|
||||
$this->httpClient,
|
||||
$this->bus,
|
||||
'http://meilisearch:7700',
|
||||
'test-key',
|
||||
$this->cache,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user