Source for file Backend.php
Documentation is available at Backend.php
declare(encoding = "utf-8");
* This file is part of ForwardFW a web application framework.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @author Alexander Opitz <opitz.alexander@primacom.net>
* @copyright 2009-2010 The Authors
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link http://forwardfw.sourceforge.net
* @since File available since Release 0.0.8
require_once 'ForwardFW/Config/Cache/Backend.php';
require_once 'ForwardFW/Interface/Application.php';
require_once 'ForwardFW/Interface/Cache/Backend.php';
require_once 'ForwardFW/Cache/Exception/TimeOut.php';
require_once 'ForwardFW/Cache/Exception/NoData.php';
require_once 'ForwardFW/Cache/Exception/IsGenerating.php';
* Implementation of a Cache Backend.
* @author Alexander Opitz <opitz.alexander@primacom.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link http://forwardfw.sourceforge.net
* @param ForwardFW_Interface_Application $application The running application.
* @param ForwardFW_Config_Cache_Backend $config Backend config.
ForwardFW_Interface_Application $application,
ForwardFW_Config_Cache_Backend $config
$this->application = $application;
* @param string $strHash Hash for data.
* @param integer $nTime Oldest Time of data in cache.
* @return mixed Data from cache
* @throws ForwardFW_Cache_Exception_IsGenerating
* @throws ForwardFW_Cache_Exception_TimeOut
* @throws ForwardFW_Cache_Exception_NoData
public function getData($strHash, $nTime)
if ($arData['time'] > $nTime) {
if (!$arData['generating']) {
$this->application->getResponse()->addLog(
$this->application->getResponse()->addLog(
'Cache Backend: Data isGenerating'
// Data but timed out exception
$this->application->getResponse()->addLog(
'Cache Backend: Data timed out'
$this->application->getResponse()->addLog(
'Cache Backend: No data available'
* @param string $strHash Hash for data.
* @param mixed $mData Data to save into cache.
public function setData($strHash, $mData)
* Clears data from Cache.
* @param string $strHash Hash for data.
* Sets marker that cache will be generated yet.
* @param string $strHash Hash of cache which is generated.
* Writes data into the cache
* @param string $strHash Hash for data.
* @param array $arData Data to save into cache.
abstract protected function writeData($strHash, array $arData);
* Reads data from the cache
* @param string $strHash Hash for data.
* @return array Data from the storage
abstract protected function readData($strHash);
* Removes data from the cache
* @param string $strHash Hash for data.
* @return boolean Returns true if data removed otherwise false.
abstract protected function clear();
|