1 <?php
2 /**
3 * Part of the Joomla Framework Session Package
4 *
5 * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE
7 */
8
9 namespace Joomla\Session\Storage;
10
11 use Joomla\Session\Storage;
12
13 /**
14 * APC session storage handler for PHP
15 *
16 * @see http://www.php.net/manual/en/function.session-set-save-handler.php
17 * @since 1.0
18 * @deprecated 2.0 The Storage class chain will be removed.
19 */
20 class Apc extends Storage
21 {
22 /**
23 * Constructor
24 *
25 * @param array $options Optional parameters
26 *
27 * @since 1.0
28 * @throws \RuntimeException
29 * @deprecated 2.0
30 */
31 public function __construct($options = array())
32 {
33 if (!self::isSupported())
34 {
35 throw new \RuntimeException('APC Extension is not available', 404);
36 }
37
38 parent::__construct($options);
39 }
40
41 /**
42 * Read the data for a particular session identifier from the
43 * SessionHandler backend.
44 *
45 * @param string $id The session identifier.
46 *
47 * @return string The session data.
48 *
49 * @since 1.0
50 * @deprecated 2.0
51 */
52 public function read($id)
53 {
54 $sess_id = 'sess_' . $id;
55
56 return (string) apc_fetch($sess_id);
57 }
58
59 /**
60 * Write session data to the SessionHandler backend.
61 *
62 * @param string $id The session identifier.
63 * @param string $session_data The session data.
64 *
65 * @return boolean True on success, false otherwise.
66 *
67 * @since 1.0
68 * @deprecated 2.0
69 */
70 public function write($id, $session_data)
71 {
72 $sess_id = 'sess_' . $id;
73
74 return apc_store($sess_id, $session_data, ini_get("session.gc_maxlifetime"));
75 }
76
77 /**
78 * Destroy the data for a particular session identifier in the SessionHandler backend.
79 *
80 * @param string $id The session identifier.
81 *
82 * @return boolean True on success, false otherwise.
83 *
84 * @since 1.0
85 * @deprecated 2.0
86 */
87 public function destroy($id)
88 {
89 $sess_id = 'sess_' . $id;
90
91 return apc_delete($sess_id);
92 }
93
94 /**
95 * Test to see if the SessionHandler is available.
96 *
97 * @return boolean True on success, false otherwise.
98 *
99 * @since 1.0
100 * @deprecated 2.0
101 */
102 public static function isSupported()
103 {
104 return extension_loaded('apc');
105 }
106 }
107