1 | <?php |
||
17 | class PerSiteLinkCache { |
||
18 | |||
19 | const CACHE_ID_PREFIX = 'ppp-wd-pslc-'; |
||
20 | |||
21 | const CACHE_LIFE_TIME = 86400; |
||
22 | |||
23 | /** |
||
24 | * @var Cache |
||
25 | */ |
||
26 | private $cache; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $name; |
||
32 | |||
33 | /** |
||
34 | * @param Cache $cache |
||
35 | * @param string $name |
||
36 | */ |
||
37 | 3 | public function __construct(Cache $cache, $name) { |
|
38 | 3 | $this->cache = $cache; |
|
39 | 3 | $this->name = $name; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param SiteLink $siteLink |
||
44 | * @return SiteLinkProvider |
||
45 | */ |
||
46 | 2 | public function fetch(SiteLink $siteLink) { |
|
47 | $result = $this->cache->fetch($this->getCacheId($siteLink)); |
||
48 | |||
49 | 2 | if($result === false) { |
|
50 | throw new OutOfBoundsException('The search is not in the cache.'); |
||
51 | } |
||
52 | |||
53 | 1 | return $result; |
|
54 | 2 | } |
|
55 | |||
56 | /** |
||
57 | * @param SiteLink $siteLink |
||
58 | * @return bool |
||
59 | */ |
||
60 | 2 | public function contains(SiteLink $siteLink) { |
|
63 | |||
64 | /** |
||
65 | * @param SiteLinkProvider $value |
||
66 | */ |
||
67 | 3 | public function save(SiteLinkProvider $value) { |
|
76 | |||
77 | 1 | private function getCacheId(SiteLink $siteLink) { |
|
80 | |||
81 | private function normalizeTitle($title) { |
||
84 | } |
||
85 |