Redis cache driver --- fast, persistent caching backed by Redis for production workloads.
composer require marko/cache-redisuse Marko\Cache\Contracts\CacheInterface;
class SessionStore
{
public function __construct(
private CacheInterface $cache,
) {}
public function getSession(string $token): ?array
{
return $this->cache->get("session.$token");
}
public function saveSession(string $token, array $data): void
{
$this->cache->set("session.$token", $data, ttl: 1800);
}
}Full usage, API reference, and examples: marko/cache-redis