* @param mixed $mixed * @param null $serial * @param null $ttl * @return bool * @throws common_exception_Error */ public function put($mixed, $serial = null, $ttl = null) { if ($mixed instanceof common_Serializable) { if (!is_null($serial) && $serial != $mixed->getSerial()) { throw new common_exception_Error('Serial mismatch for Serializable ' . $mixed->getSerial()); } $serial = $mixed->getSerial(); } return $this->getPsrSimpleCache()->set($serial, $mixed, $ttl); } /** * gets the entry associted to the serial * * @access public * @author Jerome Bogaerts, * @param string serial * @return common_Serializable * @throws common_cache_NotFoundException */ public function get($serial) { $returnValue = $this->getPsrSimpleCache()->get($serial, false); if ($returnValue === false && !$this->getPsrSimpleCache()->has($serial)) { $msg = "No cache entry found for '" . $serial . "'."; throw new common_cache_NotFoundException($msg); } return $returnValue; } /** * test whenever an entry associated to the serial exists * * @access public * @author Jerome Bogaerts, * @param string serial * @return boolean */ public function has($serial) { return $this->getPsrSimpleCache()->has($serial); } /** * removes an entry from the cache * * @access public * @author Jerome Bogaerts, * @param string serial * @return mixed */ public function remove($serial) { return $this->getPsrSimpleCache()->delete($serial); } /** * empties the cache * * @access public * @author Jerome Bogaerts, * @return mixed */ public function purge() { return $this->getPsrSimpleCache()->clear(); } protected function getPsrSimpleCache() : CacheInterface { return $this->getServiceLocator()->get(SimpleCache::SERVICE_ID); } }