From 9ea0b37ede9bdb124362243f61b820e72b548e17 Mon Sep 17 00:00:00 2001 From: Fred Bradley Date: Fri, 3 Nov 2023 15:40:12 +0000 Subject: [PATCH] feat: if Laravel detected, then use Laravel cache --- src/Cache.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Cache.php b/src/Cache.php index 922af77..499337d 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -6,6 +6,7 @@ use League\Flysystem\Local\LocalFilesystemAdapter; use Saloon\CachePlugin\Data\CachedResponse; use Saloon\CachePlugin\Drivers\FlysystemDriver; +use Saloon\CachePlugin\Drivers\LaravelCacheDriver; class Cache { @@ -20,10 +21,14 @@ public static function fileSystem(): Filesystem public static function driver(): FlysystemDriver { - self::purgeExpired(); - return new FlysystemDriver( - self::fileSystem() - ); + if (class_exists('\Illuminate\Support\Facades\Cache')) { + return new LaravelCacheDriver(\Illuminate\Support\Facades\Cache::getDefaultDriver()); + } else { + self::purgeExpired(); + return new FlysystemDriver( + self::fileSystem() + ); + } } public static function purgeExpired(): void