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/eaccelerator.php

Documentation is available at eaccelerator.php

  1. <?php
  2. /**
  3.  * @version        $Id: eaccelerator.php 6472 2007-02-03 10:47:26Z pasamio $
  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.  * eAccelerator cache storage handler
  20.  *
  21.  * @author        Louis Landry <[email protected]>
  22.  * @package        Joomla.Framework
  23.  * @subpackage    Cache
  24.  * @since        1.5
  25.  */
  26. {
  27.     /**
  28.     * Constructor
  29.     *
  30.     * @access protected
  31.     * @param array $options optional parameters
  32.     */
  33.     function __construct$options array() )
  34.     {
  35.         parent::__construct($options);
  36.  
  37.         $config            =JFactory::getConfig();
  38.         $this->_hash    $config->getValue('config.secret');
  39.     }
  40.  
  41.     /**
  42.      * Get cached data from eAccelerator by id and group
  43.      *
  44.      * @access    public
  45.      * @param    string    $id            The cache data id
  46.      * @param    string    $group        The cache data group
  47.      * @param    boolean    $checkTime    True to verify cache time expiration threshold
  48.      * @return    mixed    Boolean false on failure or a cached data string
  49.      * @since    1.5
  50.      */
  51.     function get($id$group$checkTime)
  52.     {
  53.         $cache_id $this->_getCacheId($id$group);
  54.         return eaccelerator_get($cache_id);
  55.     }
  56.  
  57.     /**
  58.      * Store the data to eAccelerator by id and group
  59.      *
  60.      * @access    public
  61.      * @param    string    $id        The cache data id
  62.      * @param    string    $group    The cache data group
  63.      * @param    string    $data    The data to store in cache
  64.      * @return    boolean    True on success, false otherwise
  65.      * @since    1.5
  66.      */
  67.     function store($id$group$data)
  68.     {
  69.         $cache_id $this->_getCacheId($id$group);
  70.         return eaccelerator_put($cache_id$data$this->_lifetime);
  71.     }
  72.  
  73.     /**
  74.      * Remove a cached data entry by id and group
  75.      *
  76.      * @access    public
  77.      * @param    string    $id        The cache data id
  78.      * @param    string    $group    The cache data group
  79.      * @return    boolean    True on success, false otherwise
  80.      * @since    1.5
  81.      */
  82.     function remove($id$group)
  83.     {
  84.         $cache_id $this->_getCacheId($id$group);
  85.         return eaccelerator_rm($cache_id);
  86.     }
  87.  
  88.     /**
  89.      * Clean cache for a group given a mode.
  90.      *
  91.      * group mode        : cleans all cache in the group
  92.      * notgroup mode    : cleans all cache not in the group
  93.      *
  94.      * @access    public
  95.      * @param    string    $group    The cache data group
  96.      * @param    string    $mode    The mode for cleaning cache [group|notgroup]
  97.      * @return    boolean    True on success, false otherwise
  98.      * @since    1.5
  99.      */
  100.     function clean($group$mode)
  101.     {
  102.         $return true;
  103.         $folder    md5($group.'-'.$this->_hash);
  104.         switch ($mode)
  105.         {
  106.             case 'notgroup':
  107.                 // Get list of cache entries by folder and delete those not in $folder
  108.                 break;
  109.             case 'group':
  110.             default:
  111.                 // Get list of cache entries by folder and delete those in $folder
  112.                 break;
  113.         }
  114.         return $return;
  115.     }
  116.  
  117.     /**
  118.      * Garbage collect expired cache data
  119.      *
  120.      * @access public
  121.      * @return boolean  True on success, false otherwise.
  122.      */
  123.     function gc()
  124.     {
  125.         return eaccelerator_gc();
  126.     }
  127.  
  128.     /**
  129.      * Test to see if the cache storage is available.
  130.      *
  131.      * @static
  132.      * @access public
  133.      * @return boolean  True on success, false otherwise.
  134.      */
  135.     function test()
  136.     {
  137.         return (extension_loaded('eaccelerator'&& function_exists('eaccelerator_get'));
  138.     }
  139.  
  140.     /**
  141.      * Get a cache_id string from an id/group pair
  142.      *
  143.      * @access    private
  144.      * @param    string    $id        The cache data id
  145.      * @param    string    $group    The cache data group
  146.      * @return    string    The cache_id string
  147.      * @since    1.5
  148.      */
  149.     function _getCacheId($id$group)
  150.     {
  151.         $folder    md5($group.'-'.$this->_hash);
  152.         $name    md5($id.'-'.$this->_hash);
  153.  
  154.         return 'cache_'.$folder.DS.$name;
  155.     }
  156. }
  157. ?>

Documentation generated on Mon, 05 Mar 2007 20:57:04 +0000 by phpDocumentor 1.3.1