From a265984415dd5575ca0d9f6f44d110268baf5bdc Mon Sep 17 00:00:00 2001 From: Rostislav Kaleta Date: Tue, 10 Dec 2024 08:52:05 +0100 Subject: [PATCH] notify user that he is trying to use RR KV without installing corresponding php package --- src/Cache/KVCacheAdapter.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Cache/KVCacheAdapter.php b/src/Cache/KVCacheAdapter.php index 5b6bcfe..2e8b414 100644 --- a/src/Cache/KVCacheAdapter.php +++ b/src/Cache/KVCacheAdapter.php @@ -2,6 +2,7 @@ namespace FluffyDiscord\RoadRunnerBundle\Cache; +use FluffyDiscord\RoadRunnerBundle\Exception\CacheAutoRegisterException; use FluffyDiscord\RoadRunnerBundle\Exception\SodiumKeypairException; use FluffyDiscord\RoadRunnerBundle\Exception\SodiumNotEnabledException; use Spiral\Goridge\RPC\RPCInterface; @@ -10,6 +11,7 @@ use Spiral\RoadRunner\KeyValue\Serializer\IgbinarySerializer; use Spiral\RoadRunner\KeyValue\Serializer\SodiumSerializer; use Symfony\Component\Cache\Adapter\Psr16Adapter; +use Spiral\RoadRunner\KeyValue\Cache; class KVCacheAdapter extends Psr16Adapter { @@ -22,6 +24,10 @@ public static function create( ?string $keypairPath, ): self { + if (!class_exists(Cache::class)) { + throw new CacheAutoRegisterException("Run 'composer require spiral/roadrunner-kv' to enable RoadRunner KV cache"); + } + $serializer = null; if ($serializerClass === null && function_exists("igbinary_serialize")) { $serializer = new IgbinarySerializer();