Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
apc.php
Aller à la documentation de ce fichier.
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  */
21 {
22  /**
23  * Constructor
24  *
25  * @param array $options Optional parameters
26  *
27  * @since 11.1
28  * @throws RuntimeException
29  */
30  public function __construct($options = array())
31  {
32  if (!self::isSupported())
33  {
34  throw new RuntimeException('APC Extension is not available', 404);
35  }
36 
37  parent::__construct($options);
38  }
39 
40  /**
41  * Read the data for a particular session identifier from the
42  * SessionHandler backend.
43  *
44  * @param string $id The session identifier.
45  *
46  * @return string The session data.
47  *
48  * @since 11.1
49  */
50  public function read($id)
51  {
52  $sess_id = 'sess_' . $id;
53  return (string) apc_fetch($sess_id);
54  }
55 
56  /**
57  * Write session data to the SessionHandler backend.
58  *
59  * @param string $id The session identifier.
60  * @param string $session_data The session data.
61  *
62  * @return boolean True on success, false otherwise.
63  *
64  * @since 11.1
65  */
66  public function write($id, $session_data)
67  {
68  $sess_id = 'sess_' . $id;
69  return apc_store($sess_id, $session_data, ini_get("session.gc_maxlifetime"));
70  }
71 
72  /**
73  * Destroy the data for a particular session identifier in the SessionHandler backend.
74  *
75  * @param string $id The session identifier.
76  *
77  * @return boolean True on success, false otherwise.
78  *
79  * @since 11.1
80  */
81  public function destroy($id)
82  {
83  $sess_id = 'sess_' . $id;
84  return apc_delete($sess_id);
85  }
86 
87  /**
88  * Test to see if the SessionHandler is available.
89  *
90  * @return boolean True on success, false otherwise.
91  *
92  * @since 12.1
93  */
94  public static function isSupported()
95  {
96  return extension_loaded('apc');
97  }
98 }