Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/cache/storage.php

Documentation is available at storage.php

  1. <?php
  2. /**
  3. @version        $Id: session.php 6157 2007-01-03 00:22:09Z Jinx $
  4. @package        Joomla.Framework
  5. @subpackage    Cache
  6. @copyright    Copyright (C) 2005 - 2007 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.  * @author        Louis Landry <[email protected]>
  23.  * @package        Joomla.Framework
  24.  * @subpackage    Cache
  25.  * @since        1.5
  26.  */
  27. class JCacheStorage extends JObject
  28. {
  29.     /**
  30.     * Constructor
  31.     *
  32.     * @access protected
  33.     * @param array $options optional parameters
  34.     */
  35.     function __construct$options array() )
  36.     {
  37.         $this->_application    (isset($options['application'])) $options['application'null;
  38.         $this->_locking        (isset($options['locking'])) $options['locking'true;
  39.         $this->_lifetime    (isset($options['lifetime'])) $options['lifetime'null;
  40.         $this->_now            time();
  41.  
  42.          // Set time threshold value
  43.         if (is_null($this->_lifetime)) {
  44.             $this->_threshold 0;
  45.         else {
  46.             $this->_threshold $this->_now $this->_lifetime;
  47.         }
  48.     }
  49.  
  50.     /**
  51.      * Returns a reference to a cache storage hanlder object, only creating it
  52.      * if it doesn't already exist.
  53.      *
  54.      * @static
  55.      * @param    string    $handler    The cache storage handler to instantiate
  56.      * @return    object    JCacheStorageHandler object
  57.      * @since    1.5
  58.      */
  59.     function &getInstance($handler 'file'$options array())
  60.     {
  61.         static $instances;
  62.  
  63.         if (!isset ($instances)) {
  64.             $instances array ();
  65.         }
  66.  
  67.         $handler strtolower($handler);
  68.         if (!isset($instances[$handler]))
  69.         {
  70.             jimport('joomla.cache.storage.'.$handler);
  71.             $class 'JCacheStorage'.ucfirst($handler);
  72.             if (class_exists($class)) {
  73.                 $instances[$handlernew $class($options);
  74.             else {
  75.                 return JError::raiseWarning(500'Invalid Cache Type: '.$handler);
  76.             }
  77.         }
  78.         return $instances[$handler];
  79.     }
  80.  
  81.     /**
  82.      * Get cached data by id and group
  83.      *
  84.      * @abstract
  85.      * @access    public
  86.      * @param    string    $id            The cache data id
  87.      * @param    string    $group        The cache data group
  88.      * @param    boolean    $checkTime    True to verify cache time expiration threshold
  89.      * @return    mixed    Boolean false on failure or a cached data string
  90.      * @since    1.5
  91.      */
  92.     function get($id$group$checkTime)
  93.     {
  94.         return;
  95.     }
  96.  
  97.     /**
  98.      * Store the data to cache by id and group
  99.      *
  100.      * @abstract
  101.      * @access    public
  102.      * @param    string    $id        The cache data id
  103.      * @param    string    $group    The cache data group
  104.      * @param    string    $data    The data to store in cache
  105.      * @return    boolean    True on success, false otherwise
  106.      * @since    1.5
  107.      */
  108.     function store($id$group$data)
  109.     {
  110.         return true;
  111.     }
  112.  
  113.     /**
  114.      * Remove a cached data entry by id and group
  115.      *
  116.      * @abstract
  117.      * @access    public
  118.      * @param    string    $id        The cache data id
  119.      * @param    string    $group    The cache data group
  120.      * @return    boolean    True on success, false otherwise
  121.      * @since    1.5
  122.      */
  123.     function remove($id$group)
  124.     {
  125.         return true;
  126.     }
  127.  
  128.     /**
  129.      * Clean cache for a group given a mode.
  130.      *
  131.      * group mode        : cleans all cache in the group
  132.      * notgroup mode    : cleans all cache not in the group
  133.      *
  134.      * @abstract
  135.      * @access    public
  136.      * @param    string    $group    The cache data group
  137.      * @param    string    $mode    The mode for cleaning cache [group|notgroup]
  138.      * @return    boolean    True on success, false otherwise
  139.      * @since    1.5
  140.      */
  141.     function clean($group$mode)
  142.     {
  143.         return true;
  144.     }
  145.  
  146.     /**
  147.      * Garbage collect expired cache data
  148.      *
  149.      * @abstract
  150.      * @access public
  151.      * @return boolean  True on success, false otherwise.
  152.      */
  153.     function gc()
  154.     {
  155.         return true;
  156.     }
  157.  
  158.     /**
  159.      * Test to see if the storage handler is available.
  160.      *
  161.      * @abstract
  162.      * @static
  163.      * @access public
  164.      * @return boolean  True on success, false otherwise.
  165.      */
  166.     function test()
  167.     {
  168.         return true;
  169.     }
  170. }
  171. ?>

Documentation generated on Mon, 05 Mar 2007 21:26:55 +0000 by phpDocumentor 1.3.1