1 | <?php |
||
17 | class JsonLdDataValueFormatterCache { |
||
18 | |||
19 | const CACHE_ID_PREFIX = 'ppp-wd-jsonld-dv-'; |
||
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 | */ |
||
36 | 3 | public function __construct(Cache $cache, $name) { |
|
37 | 3 | $this->cache = $cache; |
|
38 | 3 | $this->name = $name; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param DataValue $dataValue |
||
43 | * @return stdClass |
||
44 | */ |
||
45 | 2 | public function fetch(DataValue $dataValue) { |
|
46 | $result = $this->cache->fetch($this->getCacheId($dataValue)); |
||
47 | |||
48 | 2 | if($result === false) { |
|
49 | throw new OutOfBoundsException('The search is not in the cache.'); |
||
50 | } |
||
51 | |||
52 | 1 | return $result; |
|
53 | 2 | } |
|
54 | |||
55 | /** |
||
56 | * @param DataValue $dataValue |
||
57 | * @return bool |
||
58 | */ |
||
59 | 2 | public function contains(DataValue $dataValue) { |
|
62 | |||
63 | /** |
||
64 | * @param DataValue $dataValue |
||
65 | * @param stdClass $jsonLd |
||
66 | */ |
||
67 | 3 | public function save(DataValue $dataValue, stdClass $jsonLd) { |
|
76 | |||
77 | 1 | private function getCacheId(DataValue $dataValue) { |
|
80 | } |
||
81 |