totalSpace === null) { $path = ini_get('zend_datacache.disk.save_path'); ErrorHandler::start(); $total = disk_total_space($path); $error = ErrorHandler::stop(); if ($total === false) { throw new Exception\RuntimeException("Can't detect total space of '{$path}'", 0, $error); } $this->totalSpace = $total; } return $this->totalSpace; } /* AvailableSpaceCapableInterface */ /** * Get available space in bytes * * @throws Exception\RuntimeException * @return int|float */ public function getAvailableSpace() { $path = ini_get('zend_datacache.disk.save_path'); ErrorHandler::start(); $avail = disk_free_space($path); $error = ErrorHandler::stop(); if ($avail === false) { throw new Exception\RuntimeException("Can't detect free space of '{$path}'", 0, $error); } return $avail; } /* internal */ /** * Store data into Zend Data Disk Cache * * @param string $internalKey * @param mixed $value * @param int $ttl * @return void * @throws Exception\RuntimeException */ protected function zdcStore($internalKey, $value, $ttl) { if (!zend_disk_cache_store($internalKey, $value, $ttl)) { $valueType = gettype($value); throw new Exception\RuntimeException( "zend_disk_cache_store($internalKey, <{$valueType}>, {$ttl}) failed" ); } } /** * Fetch a single item from Zend Data Disk Cache * * @param string $internalKey * @return mixed The stored value or NULL if item wasn't found * @throws Exception\RuntimeException */ protected function zdcFetch($internalKey) { return zend_disk_cache_fetch((string) $internalKey); } /** * Fetch multiple items from Zend Data Disk Cache * * @param array $internalKeys * @return array All found items * @throws Exception\RuntimeException */ protected function zdcFetchMulti(array $internalKeys) { $items = zend_disk_cache_fetch($internalKeys); if ($items === false) { throw new Exception\RuntimeException("zend_disk_cache_fetch() failed"); } return $items; } /** * Delete data from Zend Data Disk Cache * * @param string $internalKey * @return bool * @throws Exception\RuntimeException */ protected function zdcDelete($internalKey) { return zend_disk_cache_delete($internalKey); } }