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 16 17 18 19 20
21 class RedisSession extends AbstractCacheSession {
22
23 24 25 26 27 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 48 49 50 51 52 53
54 static function RedisSession() {
55 return new RedisSession();
56 }
57
58 }