1 | <?php namespace Arcanedev\LaravelMetrics\Metrics\Concerns; |
||
14 | trait HasCachedResults |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Getters |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * Get the Http request instance. |
||
23 | * |
||
24 | * @return \Illuminate\Http\Request |
||
25 | */ |
||
26 | abstract public function getRequest(); |
||
27 | |||
28 | /* ----------------------------------------------------------------- |
||
29 | | Main Methods |
||
30 | | ----------------------------------------------------------------- |
||
31 | */ |
||
32 | |||
33 | /** |
||
34 | * Determine for how many minutes the metric should be cached. |
||
35 | * |
||
36 | * @return \DateTimeInterface|\DateInterval|float|int|void |
||
37 | */ |
||
38 | 92 | public function cacheFor() |
|
42 | |||
43 | /** |
||
44 | * Cache the result. |
||
45 | * |
||
46 | * @param mixed $cacheFor |
||
47 | * @param \Closure $callback |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 8 | protected function cacheResult($cacheFor, Closure $callback) |
|
58 | |||
59 | /** |
||
60 | * Get the cache's key. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 8 | protected function getCacheKey(): string |
|
77 | |||
78 | /** |
||
79 | * Get the cache's prefix. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | 8 | protected function getCachePrefix(): string |
|
87 | } |
||
88 |