Support Joomla!

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /joomla/cache/storage.php

Documentation is available at storage.php

  1. <?php
  2. /**
  3. @version        $Id:storage.php 6961 2007-03-15 16:06:53Z tcp $
  4. @package        Joomla.Framework
  5. @subpackage    Cache
  6. @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * Abstract cache storage handler
  20.  *
  21.  * @abstract
  22.  * @package        Joomla.Framework
  23.  * @subpackage    Cache
  24.  * @since        1.5
  25.  */
  26. class JCacheStorage extends JObject
  27. {
  28.     /**
  29.     * Constructor
  30.     *
  31.     * @access protected
  32.     * @param array $options optional parameters
  33.     */
  34.     function __construct$options array() )
  35.     {
  36.         $this->_application    (isset($options['application'])) $options['application'null;
  37.         $this->_language    (isset($options['language'])) $options['language''en-GB';
  38.         $this->_locking        (isset($options['locking'])) $options['locking'true;
  39.         $this->_lifetime    (isset($options['lifetime'])) $options['lifetime'null;
  40.         $this->_now        (isset($options['now'])) $options['now'time();
  41.  
  42.         // Set time threshold value.  If the lifetime is not set, default to 60 (0 is BAD)
  43.         // _threshold is now available ONLY as a legacy (it's deprecated).  It's no longer used in the core.
  44.         if (empty($this->_lifetime)) {
  45.             $this->_threshold $this->_now 60;
  46.             $this->_lifetime 60;
  47.         else {
  48.             $this->_threshold $this->_now $this->_lifetime;
  49.         }
  50.     }
  51.  
  52.     /**
  53.      * Returns a reference to a cache storage hanlder object, only creating it
  54.      * if it doesn't already exist.
  55.      *
  56.      * @static
  57.      * @param    string    $handler    The cache storage handler to instantiate
  58.      * @return    object    JCacheStorageHandler object
  59.      * @since    1.5
  60.      */
  61.     function &getInstance($handler 'file'$options array())
  62.     {
  63.         static $now null;
  64.         if(is_null($now)) {
  65.             $now time();
  66.         }
  67.         $options['now'$now;
  68.         //We can't cache this since options may change...
  69.                 $handler strtolower(preg_replace('/[^A-Z0-9_\.-]/i'''$handler));
  70.         $class   'JCacheStorage'.ucfirst($handler);
  71.         if(!class_exists($class))
  72.         {
  73.             $path dirname(__FILE__).DS.'storage'.DS.$handler.'.php';
  74.             if (file_exists($path) ) {
  75.                 require_once($path);
  76.             else {
  77.                 return JError::raiseWarning(500'Unable to load Cache Storage: '.$handler);
  78.             }
  79.         }
  80.         $return new $class($options);
  81.         return $return;
  82.     }
  83.  
  84.     /**
  85.      * Get cached data by id and group
  86.      *
  87.      * @abstract
  88.      * @access    public
  89.      * @param    string    $id            The cache data id
  90.      * @param    string    $group        The cache data group
  91.      * @param    boolean    $checkTime    True to verify cache time expiration threshold
  92.      * @return    mixed    Boolean false on failure or a cached data string
  93.      * @since    1.5
  94.      */
  95.     function get($id$group$checkTime)
  96.     {
  97.         return;
  98.     }
  99.  
  100.     /**
  101.      * Store the data to cache by id and group
  102.      *
  103.      * @abstract
  104.      * @access    public
  105.      * @param    string    $id        The cache data id
  106.      * @param    string    $group    The cache data group
  107.      * @param    string    $data    The data to store in cache
  108.      * @return    boolean    True on success, false otherwise
  109.      * @since    1.5
  110.      */
  111.     function store($id$group$data)
  112.     {
  113.         return true;
  114.     }
  115.  
  116.     /**
  117.      * Remove a cached data entry by id and group
  118.      *
  119.      * @abstract
  120.      * @access    public
  121.      * @param    string    $id        The cache data id
  122.      * @param    string    $group    The cache data group
  123.      * @return    boolean    True on success, false otherwise
  124.      * @since    1.5
  125.      */
  126.     function remove($id$group)
  127.     {
  128.         return true;
  129.     }
  130.  
  131.     /**
  132.      * Clean cache for a group given a mode.
  133.      *
  134.      * group mode        : cleans all cache in the group
  135.      * notgroup mode    : cleans all cache not in the group
  136.      *
  137.      * @abstract
  138.      * @access    public
  139.      * @param    string    $group    The cache data group
  140.      * @param    string    $mode    The mode for cleaning cache [group|notgroup]
  141.      * @return    boolean    True on success, false otherwise
  142.      * @since    1.5
  143.      */
  144.     function clean($group$mode)
  145.     {
  146.         return true;
  147.     }
  148.  
  149.     /**
  150.      * Garbage collect expired cache data
  151.      *
  152.      * @abstract
  153.      * @access public
  154.      * @return boolean  True on success, false otherwise.
  155.      */
  156.     function gc()
  157.     {
  158.         return true;
  159.     }
  160.  
  161.     /**
  162.      * Test to see if the storage handler is available.
  163.      *
  164.      * @abstract
  165.      * @static
  166.      * @access public
  167.      * @return boolean  True on success, false otherwise.
  168.      */
  169.     function test()
  170.     {
  171.         return true;
  172.     }
  173. }

Documentation generated on Mon, 22 Sep 2008 12:14:54 +0100 by phpDocumentor 1.3.1