/** * Checks for the existence of a key in the cache. * * @param string $data_group The Data Group to look in. * @param string $key The key to look up. * @return boolean Indicating existence */ function exists($data_group, $key) { if ($this->_cache === null) { return false; } return $this->_cache->exists("{$data_group}-{$key}"); }
function check_dl_hit(&$context, &$dl_config) { if ($this->_no_cache || $this->_live_mode) { return false; } $dl_request_id = 'DL' . $this->generate_request_identifier($context, $dl_config); $this->_meta_cache->open(); if (!$this->_meta_cache->exists($dl_request_id)) { $this->_meta_cache->close(); unset($dl_request_id); return false; } $dl_content_id = $this->_meta_cache->get($dl_request_id); if (!$this->_meta_cache->exists($dl_content_id)) { // No expiry information (or other content metadata) in cache $this->_meta_cache->close(); unset($dl_content_id, $dl_request_id); return false; } $dl_metadata = $this->_meta_cache->get($dl_content_id); $this->_meta_cache->close(); if (time() > $dl_metadata['expires']) { // DL content expired unset($dl_metadata, $dl_content_id, $dl_request_id); return false; } unset($dl_metadata); $this->_data_cache->open(); if (!$this->_data_cache->exists($dl_content_id)) { // Ghost read, we have everything but the actual content in cache unset($dl_content_id, $dl_request_id); $this->_data_cache->close(); return false; } echo $this->_data_cache->get($dl_content_id); unset($dl_content_id, $dl_request_id); $this->_data_cache->close(); return true; }