1 | <?php |
||
17 | trait HasCachedResults |
||
18 | { |
||
19 | /* ----------------------------------------------------------------- |
||
20 | | Getters |
||
21 | | ----------------------------------------------------------------- |
||
22 | */ |
||
23 | |||
24 | /** |
||
25 | * Get the Http request instance. |
||
26 | * |
||
27 | * @return \Illuminate\Http\Request |
||
28 | */ |
||
29 | abstract public function getRequest(); |
||
30 | |||
31 | /* ----------------------------------------------------------------- |
||
32 | | Main Methods |
||
33 | | ----------------------------------------------------------------- |
||
34 | */ |
||
35 | |||
36 | /** |
||
37 | * Determine for how many minutes the metric should be cached. |
||
38 | * |
||
39 | * @return \DateTimeInterface|\DateInterval|float|int|void |
||
40 | */ |
||
41 | 124 | public function cacheFor() |
|
45 | |||
46 | /** |
||
47 | * Cache the result. |
||
48 | * |
||
49 | * @param mixed $cacheFor |
||
50 | * @param \Closure $callback |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | 8 | protected function cacheResult($cacheFor, Closure $callback) |
|
61 | |||
62 | /** |
||
63 | * Get the cache's key. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | 8 | protected function getCacheKey(): string |
|
80 | |||
81 | /** |
||
82 | * Get the cache's prefix. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 8 | protected function getCachePrefix(): string |
|
90 | } |
||
91 |