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

Documentation is available at apc.php

  1. <?php
  2. /**
  3.  * @version        $Id: apc.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.  * APC 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 APC 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 apc_fetch($cache_id);
  55.     }
  56.  
  57.     /**
  58.      * Store the data to APC 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 apc_store($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 apc_delete($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.      * Test to see if the cache storage is available.
  119.      *
  120.      * @static
  121.      * @access public
  122.      * @return boolean  True on success, false otherwise.
  123.      */
  124.     function test()
  125.     {
  126.         return extension_loaded('apc');
  127.     }
  128.  
  129.     /**
  130.      * Get a cache_id string from an id/group pair
  131.      *
  132.      * @access    private
  133.      * @param    string    $id        The cache data id
  134.      * @param    string    $group    The cache data group
  135.      * @return    string    The cache_id string
  136.      * @since    1.5
  137.      */
  138.     function _getCacheId($id$group)
  139.     {
  140.         $folder    md5($group.'-'.$this->_hash);
  141.         $name    md5($id.'-'.$this->_hash);
  142.  
  143.         return 'cache_'.$folder.DS.$name;
  144.     }
  145. }
  146. ?>

Documentation generated on Mon, 05 Mar 2007 20:52:02 +0000 by phpDocumentor 1.3.1