Source for file xcache.php

Documentation is available at xcache.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.  * XCache session storage handler
  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('XCache Extension is not available'404);
  33.         }
  34.  
  35.         parent::__construct($options);
  36.     }
  37.  
  38.     /**
  39.      * Read the data for a particular session identifier from the SessionHandler backend.
  40.      *
  41.      * @param   string  $id  The session identifier.
  42.      *
  43.      * @return  string  The session data.
  44.      *
  45.      * @since   11.1
  46.      */
  47.     public function read($id)
  48.     {
  49.         $sess_id 'sess_' $id;
  50.  
  51.         // Check if id exists
  52.         if (!xcache_isset($sess_id))
  53.         {
  54.             return;
  55.         }
  56.  
  57.         return (string) xcache_get($sess_id);
  58.     }
  59.  
  60.     /**
  61.      * Write session data to the SessionHandler backend.
  62.      *
  63.      * @param   string  $id            The session identifier.
  64.      * @param   string  $session_data  The session data.
  65.      *
  66.      * @return  boolean  True on success, false otherwise.
  67.      *
  68.      * @since   11.1
  69.      */
  70.     public function write($id$session_data)
  71.     {
  72.         $sess_id 'sess_' $id;
  73.         return xcache_set($sess_id$session_dataini_get("session.gc_maxlifetime"));
  74.     }
  75.  
  76.     /**
  77.      * Destroy the data for a particular session identifier in the SessionHandler backend.
  78.      *
  79.      * @param   string  $id  The session identifier.
  80.      *
  81.      * @return  boolean  True on success, false otherwise.
  82.      *
  83.      * @since   11.1
  84.      */
  85.     public function destroy($id)
  86.     {
  87.         $sess_id 'sess_' $id;
  88.  
  89.         if (!xcache_isset($sess_id))
  90.         {
  91.             return true;
  92.         }
  93.  
  94.         return xcache_unset($sess_id);
  95.     }
  96.  
  97.     /**
  98.      * Test to see if the SessionHandler is available.
  99.      *
  100.      * @return boolean  True on success, false otherwise.
  101.      *
  102.      * @since   12.1
  103.      */
  104.     static public function isSupported()
  105.     {
  106.         return (extension_loaded('xcache'));
  107.     }
  108. }

Documentation generated on Tue, 19 Nov 2013 15:18:35 +0100 by phpDocumentor 1.4.3