symfony/ai-cache-message-store
PSR-6 cache-backed message store for Symfony AI Chat. Persist and retrieve chat messages using any PSR-6 cache pool for lightweight conversation history across requests. Part of the Symfony AI ecosystem.
laravel-ai package) or custom implementations. This package is Symfony-specific; you’d need a wrapper layer or alternative (e.g., Laravel’s Cache facade directly).*"This package lets us store AI chat conversations in high-speed cache (like Redis) instead of expensive databases, cutting infrastructure costs by ~70% while keeping response times under 50ms. Here’s why it’s a no-brainer:
*"The symfony/ai-cache-message-store package bridges Symfony AI Chat with PSR-6 caches, enabling:
*"Add this to your Laravel/PHP app to cache AI chat messages with zero changes to your chat logic:
composer require symfony/ai-cache-message-store
How it works:
.env:
CACHE_DRIVER=redis
MessageStore with CacheMessageStore:
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\AI\Chat\MessageStore\CacheMessageStore;
$cache = Cache::store('redis')->getAdapter();
$messageStore = new CacheMessageStore($cache);
class LaravelCacheMessageStore implements MessageStoreInterface {
public function __construct(private AdapterInterface $cache) {}
public function load(string $id): ?Message { /* ... */ }
public function save(Message $message): void { /* ... */ }
// ...
}
Pro Tips:
600 seconds for active sessions).chat:user:123).Cache::stats() or Redis CLI.
Gotchas:JsonSerializable or a custom serializer.*"This package enables cost-effective storage of AI chat histories for analytics while preserving performance:
SCAN to sample cached messages for analytics, then export to a data lake (e.g., S3) forHow can I help you explore Laravel packages today?