//
// $Id$
-require_once "Cache/Error.php";
+require_once 'Cache/Error.php';
/**
* Cache is a base class for cache implementations.
*
* Usage example of the generic data cache:
*
-* require_once("Cache.php");
+* require_once('Cache.php');
*
-* $cache = new Cache("file", array("cache_dir" => "cache/") );
-* $id = $cache->generateID("testentry");
+* $cache = new Cache('file', array('cache_dir' => 'cache/') );
+* $id = $cache->generateID('testentry');
*
* if ($data = $cache->get($id)) {
* print "Cache hit.<br>Data: $data";
*
* } else {
-* $data = "data of any kind";
+* $data = 'data of any kind';
* $cache->save($id, $data);
-* print "Cache miss.<br>";
+* print 'Cache miss.<br>';
* }
*
* WARNING: No File/DB-Table-Row locking is implemented yet,
* @param string Name of storage container class
* @param array Array with storage class dependend config options
*/
- function Cache($storage_driver, $storage_options = "")
+ function Cache($storage_driver, $storage_options = '')
{
$this->PEAR();
$storage_driver = strtolower($storage_driver);
* @return mixed cached data or NULL on failure
* @access public
*/
- function get($id, $group = "default") {
+ function get($id, $group = 'default') {
if (!$this->caching)
- return "";
+ return '';
if ($this->isCached($id, $group) && !$this->isExpired($id, $group))
return $this->load($id, $group);
* @return boolean
* @access public
*/
- function save($id, $data, $expires = 0, $group = "default") {
+ function save($id, $data, $expires = 0, $group = 'default') {
if (!$this->caching)
return true;
- return $this->extSave($id, $data, "",$expires, $group);
+ return $this->extSave($id, $data, '',$expires, $group);
} // end func save
/**
* @access public
* @see getUserdata()
*/
- function extSave($id, $cachedata, $userdata, $expires = 0, $group = "default") {
+ function extSave($id, $cachedata, $userdata, $expires = 0, $group = 'default') {
if (!$this->caching)
return true;
* @return mixed cached data or NULL on failure
* @access public
*/
- function load($id, $group = "default") {
+ function load($id, $group = 'default') {
if (!$this->caching)
- return "";
+ return '';
return $this->container->load($id, $group);
} // end func load
* @access public
* @see extSave()
*/
- function getUserdata($id, $group = "default") {
+ function getUserdata($id, $group = 'default') {
if (!$this->caching)
- return "";
+ return '';
return $this->container->getUserdata($id, $group);
} // end func getUserdata
* @return boolean
* @access public
*/
- function delete($id, $group = "default") {
+ function delete($id, $group = 'default') {
if (!$this->caching)
return true;
* @param string cache group, if empty all groups will be flashed
* @return integer number of removed datasets
*/
- function flush($group = "") {
+ function flush($group = '') {
if (!$this->caching)
return true;
* @return boolean
* @access public
*/
- function isCached($id, $group = "default") {
+ function isCached($id, $group = 'default') {
if (!$this->caching)
return false;
* @return boolean
* @access public
*/
- function isExpired($id, $group = "default", $max_age = 0) {
+ function isExpired($id, $group = 'default', $max_age = 0) {
if (!$this->caching)
return true;