1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,70 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace Illuminate\Filesystem; |
|
4 |
- |
|
5 |
-use Illuminate\Contracts\Cache\Repository; |
|
6 |
-use League\Flysystem\Cached\Storage\AbstractCache; |
|
7 |
- |
|
8 |
-class Cache extends AbstractCache |
|
9 |
-{ |
|
10 |
- /** |
|
11 |
- * The cache repository implementation. |
|
12 |
- * |
|
13 |
- * @var \Illuminate\Contracts\Cache\Repository |
|
14 |
- */ |
|
15 |
- protected $repository; |
|
16 |
- |
|
17 |
- /** |
|
18 |
- * The cache key. |
|
19 |
- * |
|
20 |
- * @var string |
|
21 |
- */ |
|
22 |
- protected $key; |
|
23 |
- |
|
24 |
- /** |
|
25 |
- * The cache expiration time in seconds. |
|
26 |
- * |
|
27 |
- * @var int|null |
|
28 |
- */ |
|
29 |
- protected $expire; |
|
30 |
- |
|
31 |
- /** |
|
32 |
- * Create a new cache instance. |
|
33 |
- * |
|
34 |
- * @param \Illuminate\Contracts\Cache\Repository $repository |
|
35 |
- * @param string $key |
|
36 |
- * @param int|null $expire |
|
37 |
- */ |
|
38 |
- public function __construct(Repository $repository, $key = 'flysystem', $expire = null) |
|
39 |
- { |
|
40 |
- $this->key = $key; |
|
41 |
- $this->expire = $expire; |
|
42 |
- $this->repository = $repository; |
|
43 |
- } |
|
44 |
- |
|
45 |
- /** |
|
46 |
- * Load the cache. |
|
47 |
- * |
|
48 |
- * @return void |
|
49 |
- */ |
|
50 |
- public function load() |
|
51 |
- { |
|
52 |
- $contents = $this->repository->get($this->key); |
|
53 |
- |
|
54 |
- if (! is_null($contents)) { |
|
55 |
- $this->setFromStorage($contents); |
|
56 |
- } |
|
57 |
- } |
|
58 |
- |
|
59 |
- /** |
|
60 |
- * Persist the cache. |
|
61 |
- * |
|
62 |
- * @return void |
|
63 |
- */ |
|
64 |
- public function save() |
|
65 |
- { |
|
66 |
- $contents = $this->getForStorage(); |
|
67 |
- |
|
68 |
- $this->repository->put($this->key, $contents, $this->expire); |
|
69 |
- } |
|
70 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,70 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace Illuminate\Filesystem; |
|
4 |
+ |
|
5 |
+use Illuminate\Contracts\Cache\Repository; |
|
6 |
+use League\Flysystem\Cached\Storage\AbstractCache; |
|
7 |
+ |
|
8 |
+class Cache extends AbstractCache |
|
9 |
+{ |
|
10 |
+ /** |
|
11 |
+ * The cache repository implementation. |
|
12 |
+ * |
|
13 |
+ * @var \Illuminate\Contracts\Cache\Repository |
|
14 |
+ */ |
|
15 |
+ protected $repository; |
|
16 |
+ |
|
17 |
+ /** |
|
18 |
+ * The cache key. |
|
19 |
+ * |
|
20 |
+ * @var string |
|
21 |
+ */ |
|
22 |
+ protected $key; |
|
23 |
+ |
|
24 |
+ /** |
|
25 |
+ * The cache expiration time in seconds. |
|
26 |
+ * |
|
27 |
+ * @var int|null |
|
28 |
+ */ |
|
29 |
+ protected $expire; |
|
30 |
+ |
|
31 |
+ /** |
|
32 |
+ * Create a new cache instance. |
|
33 |
+ * |
|
34 |
+ * @param \Illuminate\Contracts\Cache\Repository $repository |
|
35 |
+ * @param string $key |
|
36 |
+ * @param int|null $expire |
|
37 |
+ */ |
|
38 |
+ public function __construct(Repository $repository, $key = 'flysystem', $expire = null) |
|
39 |
+ { |
|
40 |
+ $this->key = $key; |
|
41 |
+ $this->expire = $expire; |
|
42 |
+ $this->repository = $repository; |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ /** |
|
46 |
+ * Load the cache. |
|
47 |
+ * |
|
48 |
+ * @return void |
|
49 |
+ */ |
|
50 |
+ public function load() |
|
51 |
+ { |
|
52 |
+ $contents = $this->repository->get($this->key); |
|
53 |
+ |
|
54 |
+ if (! is_null($contents)) { |
|
55 |
+ $this->setFromStorage($contents); |
|
56 |
+ } |
|
57 |
+ } |
|
58 |
+ |
|
59 |
+ /** |
|
60 |
+ * Persist the cache. |
|
61 |
+ * |
|
62 |
+ * @return void |
|
63 |
+ */ |
|
64 |
+ public function save() |
|
65 |
+ { |
|
66 |
+ $contents = $this->getForStorage(); |
|
67 |
+ |
|
68 |
+ $this->repository->put($this->key, $contents, $this->expire); |
|
69 |
+ } |
|
70 |
+} |