6 * Requirements: PHP5, SimpleXML
8 * Copyright (c) 2008 PHPIDS group (https://phpids.org)
10 * PHPIDS is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, version 3 of the License, or
13 * (at your option) any later version.
15 * PHPIDS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with PHPIDS. If not, see <http://www.gnu.org/licenses/>.
27 * @author Mario Heiderich <mario.heiderich@gmail.com>
28 * @author Christian Matthies <ch0012@gmail.com>
29 * @author Lars Strojny <lars@strojny.net>
30 * @license http://www.gnu.org/licenses/lgpl.html LGPL
31 * @link http://php-ids.org/
34 require_once 'IDS/Caching/Interface.php';
37 * File caching wrapper
39 * This class inhabits functionality to get and set cache via session.
43 * @author Christian Matthies <ch0012@gmail.com>
44 * @author Mario Heiderich <mario.heiderich@gmail.com>
45 * @author Lars Strojny <lars@strojny.net>
46 * @copyright 2007-2009 The PHPIDS Group
47 * @license http://www.gnu.org/licenses/lgpl.html LGPL
48 * @version Release: $Id:Session.php 517 2007-09-15 15:04:13Z mario $
49 * @link http://php-ids.org/
52 class IDS_Caching_Session
implements IDS_Caching_Interface
67 private $config = null;
70 * Holds an instance of this class
74 private static $cachingInstance = null;
79 * @param string $type caching type
80 * @param object $init the IDS_Init object
84 public function __construct($type, $init)
87 $this->config
= $init->config
['Caching'];
91 * Returns an instance of this class
93 * @param string $type caching type
94 * @param object $init the IDS_Init object
96 * @return object $this
98 public static function getInstance($type, $init)
101 if (!self
::$cachingInstance) {
102 self
::$cachingInstance = new IDS_Caching_Session($type, $init);
105 return self
::$cachingInstance;
109 * Writes cache data into the session
111 * @param array $data the caching data
113 * @return object $this
115 public function setCache(array $data)
118 $_SESSION['PHPIDS'][$this->type
] = $data;
123 * Returns the cached data
125 * Note that this method returns false if either type or file cache is not set
127 * @return mixed cache data or false
129 public function getCache()
132 if ($this->type
&& $_SESSION['PHPIDS'][$this->type
]) {
133 return $_SESSION['PHPIDS'][$this->type
];
145 * vim600: sw=4 ts=4 expandtab