Source for file memcache.php

Documentation is available at memcache.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Session
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Memcache session storage handler for PHP
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Session
  17.  * @since       11.1
  18.  */
  19. {
  20.     /**
  21.      * Constructor
  22.      *
  23.      * @param   array  $options  Optional parameters.
  24.      *
  25.      * @since   11.1
  26.      * @throws  RuntimeException
  27.      */
  28.     public function __construct($options array())
  29.     {
  30.         if (!self::isSupported())
  31.         {
  32.             throw new RuntimeException('Memcache Extension is not available'404);
  33.         }
  34.  
  35.         parent::__construct($options);
  36.  
  37.         $config JFactory::getConfig();
  38.  
  39.         // This will be an array of loveliness
  40.         // @todo: multiple servers
  41.         $this->_servers array(
  42.             array(
  43.                 'host' => $config->get('memcache_server_host''localhost'),
  44.                 'port' => $config->get('memcache_server_port'11211)
  45.             )
  46.         );
  47.     }
  48.  
  49.     /**
  50.      * Register the functions of this class with PHP's session handler
  51.      *
  52.      * @return  void 
  53.      *
  54.      * @since   12.2
  55.      */
  56.     public function register()
  57.     {
  58.         ini_set('session.save_path'$this->_servers['host'':' $this->_servers['port']);
  59.         ini_set('session.save_handler''memcache');
  60.     }
  61.  
  62.     /**
  63.      * Test to see if the SessionHandler is available.
  64.      *
  65.      * @return boolean  True on success, false otherwise.
  66.      *
  67.      * @since   12.1
  68.      */
  69.     static public function isSupported()
  70.     {
  71.         return (extension_loaded('memcache'&& class_exists('Memcache'));
  72.     }
  73. }

Documentation generated on Tue, 19 Nov 2013 15:07:44 +0100 by phpDocumentor 1.4.3