1 | <?php |
||
17 | class LaravelCacheAdapter implements CacheInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $prefix; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $store; |
||
28 | |||
29 | /** |
||
30 | * @var CacheManager |
||
31 | */ |
||
32 | private $manager; |
||
33 | |||
34 | 84 | public function __construct(CacheManager $manager, $store, $prefix = null) |
|
40 | |||
41 | /** |
||
42 | * @inheritdoc |
||
43 | */ |
||
44 | 14 | public function get($key) |
|
45 | { |
||
46 | 14 | return $this->getCache()->get($this->generateKey($key)); |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | 14 | public function remove($key) |
|
56 | |||
57 | /** |
||
58 | * @inheritdoc |
||
59 | */ |
||
60 | 56 | public function set($key, $value, $ttl = 0) |
|
64 | |||
65 | /** |
||
66 | * Generate a cache key which incorporates the prefix. |
||
67 | * |
||
68 | * @param $key |
||
69 | * @return string |
||
70 | */ |
||
71 | 84 | protected function generateKey($key) |
|
75 | |||
76 | /** |
||
77 | * The AWS CacheInterface takes input in seconds, but the Laravel Cache classes use minutes. To support |
||
78 | * this intelligently, we round up to one minute for any value less than 60 seconds, and round down to |
||
79 | * the nearest whole minute for any value over one minute. First, if the passed in TTL is 0 we return |
||
80 | * 0 to allow an unlimited cache lifetime. |
||
81 | * |
||
82 | * @param $ttl |
||
83 | * @return float|int |
||
84 | */ |
||
85 | 56 | protected function convertTtl($ttl) |
|
99 | |||
100 | /** |
||
101 | * Returns the configured Laravel Cache Store |
||
102 | * |
||
103 | * @return mixed |
||
104 | */ |
||
105 | 84 | protected function getCache() |
|
109 | } |
||
110 |