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

Documentation is available at xcache.php

  1. <?php
  2. /**
  3.  * @version        $id:$
  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.  * XCache cache storage handler
  20.  *
  21.  * @package        Joomla.Framework
  22.  * @subpackage    Cache
  23.  * @since        1.5
  24.  */
  25. {
  26.     /**
  27.     * Constructor
  28.     *
  29.     * @access protected
  30.     * @param array $options optional parameters
  31.     */
  32.     function __construct$options array() )
  33.     {
  34.         parent::__construct($options);
  35.  
  36.         $config            =JFactory::getConfig();
  37.         $this->_hash    $config->getValue('config.secret');
  38.     }
  39.  
  40.     /**
  41.      * Get cached data by id and group
  42.      *
  43.      * @access    public
  44.      * @param    string    $id            The cache data id
  45.      * @param    string    $group        The cache data group
  46.      * @param    boolean    $checkTime    True to verify cache time expiration threshold
  47.      * @return    mixed    Boolean false on failure or a cached data string
  48.      * @since    1.5
  49.      */
  50.     function get($id$group$checkTime)
  51.     {
  52.         $cache_id $this->_getCacheId($id$group);
  53.  
  54.         //check if id exists
  55.         if!xcache_isset$cache_id ) ){
  56.             return false;
  57.         }
  58.  
  59.         return xcache_get($cache_id);
  60.     }
  61.  
  62.     /**
  63.      * Store the data by id and group
  64.      *
  65.      * @access    public
  66.      * @param    string    $id        The cache data id
  67.      * @param    string    $group    The cache data group
  68.      * @param    string    $data    The data to store in cache
  69.      * @return    boolean    True on success, false otherwise
  70.      * @since    1.5
  71.      */
  72.     function store($id$group$data)
  73.     {
  74.         $cache_id $this->_getCacheId($id$group);
  75.         return xcache_set($cache_id$data$this->_lifetime);
  76.     }
  77.  
  78.     /**
  79.      * Remove a cached data entry by id and group
  80.      *
  81.      * @access    public
  82.      * @param    string    $id        The cache data id
  83.      * @param    string    $group    The cache data group
  84.      * @return    boolean    True on success, false otherwise
  85.      * @since    1.5
  86.      */
  87.     function remove($id$group)
  88.     {
  89.         $cache_id $this->_getCacheId($id$group);
  90.  
  91.         if!xcache_isset$cache_id ) ){
  92.             return true;
  93.         }
  94.  
  95.         return xcache_unset($cache_id);
  96.     }
  97.  
  98.     /**
  99.      * Clean cache for a group given a mode.
  100.      *
  101.      * group mode        : cleans all cache in the group
  102.      * notgroup mode    : cleans all cache not in the group
  103.      *
  104.      * @access    public
  105.      * @param    string    $group    The cache data group
  106.      * @param    string    $mode    The mode for cleaning cache [group|notgroup]
  107.      * @return    boolean    True on success, false otherwise
  108.      * @since    1.5
  109.      */
  110.     function clean($group$mode)
  111.     {
  112.         return true;
  113.     }
  114.  
  115.     /**
  116.      * Test to see if the cache storage is available.
  117.      *
  118.      * @static
  119.      * @access public
  120.      * @return boolean  True on success, false otherwise.
  121.      */
  122.     function test()
  123.     {
  124.         return (extension_loaded('xcache'));
  125.     }
  126.  
  127.     /**
  128.      * Get a cache_id string from an id/group pair
  129.      *
  130.      * @access    private
  131.      * @param    string    $id        The cache data id
  132.      * @param    string    $group    The cache data group
  133.      * @return    string    The cache_id string
  134.      * @since    1.5
  135.      */
  136.     function _getCacheId($id$group)
  137.     {
  138.         $name    md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language);
  139.         return 'cache_'.$group.'-'.$name;
  140.     }
  141. }

Documentation generated on Sun, 21 Dec 2008 20:51:49 +0000 by phpDocumentor 1.3.1