Source for file apc.php

Documentation is available at apc.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.  * APC session storage handler for PHP
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Session
  17.  * @see         http://www.php.net/manual/en/function.session-set-save-handler.php
  18.  * @since       11.1
  19.  */
  20. {
  21.     /**
  22.      * Constructor
  23.      *
  24.      * @param   array  $options  Optional parameters
  25.      *
  26.      * @since   11.1
  27.      * @throws  RuntimeException
  28.      */
  29.     public function __construct($options array())
  30.     {
  31.         if (!self::isSupported())
  32.         {
  33.             throw new RuntimeException('APC Extension is not available'404);
  34.         }
  35.  
  36.         parent::__construct($options);
  37.     }
  38.  
  39.     /**
  40.      * Read the data for a particular session identifier from the
  41.      * SessionHandler backend.
  42.      *
  43.      * @param   string  $id  The session identifier.
  44.      *
  45.      * @return  string  The session data.
  46.      *
  47.      * @since   11.1
  48.      */
  49.     public function read($id)
  50.     {
  51.         $sess_id 'sess_' $id;
  52.         return (string) apc_fetch($sess_id);
  53.     }
  54.  
  55.     /**
  56.      * Write session data to the SessionHandler backend.
  57.      *
  58.      * @param   string  $id            The session identifier.
  59.      * @param   string  $session_data  The session data.
  60.      *
  61.      * @return  boolean  True on success, false otherwise.
  62.      *
  63.      * @since   11.1
  64.      */
  65.     public function write($id$session_data)
  66.     {
  67.         $sess_id 'sess_' $id;
  68.         return apc_store($sess_id$session_dataini_get("session.gc_maxlifetime"));
  69.     }
  70.  
  71.     /**
  72.      * Destroy the data for a particular session identifier in the SessionHandler backend.
  73.      *
  74.      * @param   string  $id  The session identifier.
  75.      *
  76.      * @return  boolean  True on success, false otherwise.
  77.      *
  78.      * @since   11.1
  79.      */
  80.     public function destroy($id)
  81.     {
  82.         $sess_id 'sess_' $id;
  83.         return apc_delete($sess_id);
  84.     }
  85.  
  86.     /**
  87.      * Test to see if the SessionHandler is available.
  88.      *
  89.      * @return boolean  True on success, false otherwise.
  90.      *
  91.      * @since   12.1
  92.      */
  93.     public static function isSupported()
  94.     {
  95.         return extension_loaded('apc');
  96.     }
  97. }

Documentation generated on Tue, 19 Nov 2013 14:53:42 +0100 by phpDocumentor 1.4.3