1 | <?php |
||
15 | class ApiResultToCachePersister |
||
16 | { |
||
17 | const DEFAULT_CACHE_LIFETIME = 604800; |
||
18 | const CACHE_ID_PREFIX = 'HDNET_onpage_extension'; |
||
19 | |||
20 | /** |
||
21 | * @param string $data |
||
22 | * @param string $key |
||
23 | */ |
||
24 | public function persist($data, $key) |
||
25 | { |
||
26 | /** @var CacheManager $cacheManager */ |
||
27 | $cacheManager = GeneralUtility::makeInstance(CacheManager::class); |
||
28 | $cache = $cacheManager->getCache('onpage_extension'); |
||
29 | if (!$cache->get('lastCrawlDate')) { |
||
30 | $cache->set('lastCrawlDate', date('d.m.Y')); |
||
31 | } |
||
32 | $cache->set($this->getIdentifier($key), json_encode($data)); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param string $key |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getIdentifier($key) |
||
45 | } |
||
46 |