-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathGlideCache.php
42 lines (34 loc) · 1014 Bytes
/
GlideCache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
use League\Glide\Responses\SymfonyResponseFactory;
use League\Glide\ServerFactory;
class GlideCache
{
public $server;
public function __construct()
{
$adapter = new InMemoryFilesystemAdapter();
$this->server = ServerFactory::create([
'response' => new SymfonyResponseFactory(app('request')),
'source' => Storage::getDriver(),
'cache' => config('filesystems.default') === 'minio' ? new Filesystem($adapter) : Storage::getDriver(),
'cache_path_prefix' => '.cache',
'base_url' => 'images',
'max_image_size' => 2880 * 2880,
]);
}
public function clear($path)
{
if (! $path) {
return;
}
$this->server->deleteCache($path);
}
public function getServer()
{
return $this->server;
}
}