Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

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 /pattemplate/patTemplate/TemplateCache/MMCache.php

Documentation is available at MMCache.php

  1. <?PHP
  2. /**
  3.  * patTemplate Template cache that stores data in the MMCache Cache
  4.  *
  5.  * $Id: MMCache.php 364 2005-02-19 09:39:45Z schst $
  6.  *
  7.  * @package        patTemplate
  8.  * @subpackage    Caches
  9.  * @author        Mike Valstar <[email protected]>
  10.  */
  11.  
  12. // Check to ensure this file is within the rest of the framework
  13. defined('JPATH_BASE'or die();
  14.  
  15. /**
  16.  * patTemplate Template cache that stores data in the eAccelerator Cache
  17.  *
  18.  * If the lifetime is set to auto, the cache files will be kept until
  19.  * you delete them manually.
  20.  *
  21.  * $Id: MMCache.php 364 2005-02-19 09:39:45Z schst $
  22.  *
  23.  * @package        patTemplate
  24.  * @subpackage    Caches
  25.  * @author        Mike Valstar <[email protected]>
  26.  */
  27. {
  28.    /**
  29.     * parameters of the cache
  30.     *
  31.     * @access    private
  32.     * @var        array 
  33.     */
  34.    var $_params = array'lifetime' => 'auto');
  35.  
  36.    /**
  37.     * load template from cache
  38.     *
  39.     * @access    public
  40.     * @param    string            cache key
  41.     * @param    integer            modification time of original template
  42.     * @return    array|boolean   either an array containing the templates or false cache could not be loaded
  43.     */
  44.     function load$key$modTime = -)
  45.     {
  46.         if (!function_exists('mmcache_lock')) {
  47.             return false;
  48.         }
  49.  
  50.         $something mmcache_get($key);
  51.         if (is_null($something)){
  52.             return false;
  53.         }else{
  54.             return unserialize($something);
  55.         }
  56.     }
  57.  
  58.    /**
  59.     * write template to cache
  60.     *
  61.     * @access    public
  62.     * @param    string        cache key
  63.     * @param    array        templates to store
  64.     * @return    boolean        true on success
  65.     */
  66.     function write$key$templates )
  67.     {
  68.         if (!function_exists('mmcache_lock')) {
  69.             return false;
  70.         }
  71.  
  72.         mmcache_lock($key);
  73.         if ($this->getParam'lifetime' == 'auto'){
  74.             mmcache_put($keyserialize$templates ));
  75.         }else{
  76.             mmcache_put($keyserialize$templates )$this->getParam'lifetime' 60);
  77.         }
  78.         mmcache_unlock($key);
  79.  
  80.         return true;
  81.    }
  82. }
  83. ?>

Documentation generated on Mon, 05 Mar 2007 21:10:49 +0000 by phpDocumentor 1.3.1