Skip to content

Commit 9ea0b37

Browse files
committed
feat: if Laravel detected, then use Laravel cache
1 parent 698a285 commit 9ea0b37

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Cache.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use League\Flysystem\Local\LocalFilesystemAdapter;
77
use Saloon\CachePlugin\Data\CachedResponse;
88
use Saloon\CachePlugin\Drivers\FlysystemDriver;
9+
use Saloon\CachePlugin\Drivers\LaravelCacheDriver;
910

1011
class Cache
1112
{
@@ -20,10 +21,14 @@ public static function fileSystem(): Filesystem
2021

2122
public static function driver(): FlysystemDriver
2223
{
23-
self::purgeExpired();
24-
return new FlysystemDriver(
25-
self::fileSystem()
26-
);
24+
if (class_exists('\Illuminate\Support\Facades\Cache')) {
25+
return new LaravelCacheDriver(\Illuminate\Support\Facades\Cache::getDefaultDriver());
26+
} else {
27+
self::purgeExpired();
28+
return new FlysystemDriver(
29+
self::fileSystem()
30+
);
31+
}
2732
}
2833

2934
public static function purgeExpired(): void

0 commit comments

Comments
 (0)