1 | <?php |
||
23 | abstract class AbstractCache |
||
24 | { |
||
25 | /** |
||
26 | * @var int $seconds Cache time in seconds. |
||
27 | */ |
||
28 | protected $seconds; |
||
29 | |||
30 | /** |
||
31 | * Checks whether a cached weather data is available. |
||
32 | * |
||
33 | * @param string $url The unique url of the cached content. |
||
34 | * |
||
35 | * @return bool False if no cached information is available, otherwise true. |
||
36 | * |
||
37 | * You need to check if a cached result is outdated here. Return false in that case. |
||
38 | */ |
||
39 | abstract public function isCached($url); |
||
40 | |||
41 | /** |
||
42 | * Returns cached weather data. |
||
43 | * |
||
44 | * @param string $url The unique url of the cached content. |
||
45 | * |
||
46 | * @return string|bool The cached data if it exists, false otherwise. |
||
47 | */ |
||
48 | abstract public function getCached($url); |
||
49 | |||
50 | /** |
||
51 | * Saves cached weather data. |
||
52 | * |
||
53 | * @param string $url The unique url of the cached content. |
||
54 | * @param string $content The weather data to cache. |
||
55 | * |
||
56 | * @return bool True on success, false on failure. |
||
57 | */ |
||
58 | abstract public function setCached($url, $content); |
||
59 | |||
60 | /** |
||
61 | * Set after how much seconds the cache shall expire. |
||
62 | * |
||
63 | * @param int $seconds |
||
64 | */ |
||
65 | 1 | public function setSeconds($seconds) |
|
69 | } |
||
70 |