AloFramework documentation
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alo
    • Cache
    • CLI
    • Controller
    • Db
    • Exception
    • FileSystem
    • Session
    • Statics
    • Test
    • Validators
    • Windows
  • Controller
  • None
  • PHP

Classes

  • AbstractCacheSession
  • AbstractSession
  • MemcachedSession
  • RedisSession
  • SQLSession
 1 <?php
 2 
 3    namespace Alo\Session;
 4 
 5    use Alo;
 6    use Alo\Cache\RedisWrapper;
 7    use Alo\Exception\ExtensionException as EE;
 8 
 9    if(!defined('GEN_START')) {
10       http_response_code(404);
11       die();
12    }
13 
14    /**
15     * The Redis-based session handler. ALO_SESSION_CLEANUP is not used here as
16     * cleanup is handled by the MySQL event handler
17     *
18     * @author  Art <a.molcanovas@gmail.com>
19     * @package Session
20     */
21    class RedisSession extends AbstractCacheSession {
22 
23       /**
24        * Instantiates the class
25        *
26        * @author Art <a.molcanovas@gmail.com>
27        * @throws EE When a caching class is not available
28        */
29       function __construct() {
30          if(Alo::$cache && (Alo::$cache instanceof RedisWrapper)) {
31             $this->client = &Alo::$cache;
32          } else {
33             $this->client = new RedisWrapper(true);
34          }
35 
36          if(!RedisWrapper::is_available()) {
37             throw new EE('Redis extension not loaded.', EE::E_EXT_NOT_LOADED);
38          } else {
39             parent::__construct();
40             $this->client = &Alo::$cache;
41             $this->prefix = ALO_SESSION_REDIS_PREFIX;
42             \Log::debug('Initialised Redis session');
43          }
44       }
45 
46       /**
47        * Instantiates the class
48        *
49        * @author Art <a.molcanovas@gmail.com>
50        * @throws EE When a caching class is not available
51        *
52        * @return RedisSession
53        */
54       static function RedisSession() {
55          return new RedisSession();
56       }
57 
58    }
AloFramework documentation API documentation generated by ApiGen 2.8.0