Sources for file plugins/class/cache.php in version 4.0 Beta 1
Click on a comment to hide it. Click here to show all comments.
/**
* Project: Xnyo 4: Bubbles
* File: plugins/class/cache.php
*
* Version: 4.0-dev
* SVN Id: $Id: cache.php 5 2007-05-18 03:49:07Z bok $
* SVN URL: $HeadURL:
http://svn.syd.wholesalebroadband.com.au/xnyo/trunk/plugins/class/cache.php $
* Authors: Robert Amos <bok[at]odynia.org>
*
* Copyright (c) 2001-2007 Robert Amos <bok[at]odynia.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
class XnyoCache implements XnyoClassPlugin
{
// Plugin Information
public $_plugin_info = array
(
'name' => 'Xnyo Cache Plugin',
'description' => 'Handles caching in Xnyo',
'action' => XNYO_PLUGIN_ACTION_STORAGE,
'varname' => 'cache'
);
/**
* Information Storage
**/
private $id;
private $handler;
private $xnyo;
/**
* Constructor
**/
public function __construct ()
{
// load xnyo
$this->xnyo = $GLOBALS['xnyo_parent'];
if (empty($this->xnyo->cache->handler))
throw new XnyoError('No cache handler set, but caching is enabled.');
$this->xnyo->inc($this->xnyo->cache->handler, XNYO_PLUGIN_CACHE);
$c = $this->xnyo->cache->handler;
$this->handler = new $c ();
}
/**
* Write data to the cache
**/
public function write ($data)
{
return $this->handler->write($data);
}
/**
* Is our item cached?
**/
public function is_cached ($item)
{
return $this->handler->is_cached($item);
}
/**
* Display the cache
**/
public function display_cache ($item)
{
return $this->handler->display_cache($item);
}
/**
* Return the cache
**/
public function return_cache ($item)
{
return $this->handler_display_cache($item, false);
}
}
