1 <?php
2
3 namespace Alo\Session;
4
5 use Alo;
6 use Alo\Cache\MemcachedWrapper;
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 MemcachedSession extends AbstractCacheSession {
22
23 24 25 26 27 28
29 function __construct() {
30 if(Alo::$cache && (Alo::$cache instanceof MemcachedWrapper)) {
31 $this->client = &Alo::$cache;
32 } else {
33 $this->client = new MemcachedWrapper(true);
34 }
35
36 if(!MemcachedWrapper::is_available()) {
37 throw new EE('No caching PHP extension is loaded', EE::E_EXT_NOT_LOADED);
38 } else {
39 parent::__construct();
40 $this->client = &Alo::$cache;
41 $this->prefix = ALO_SESSION_MC_PREFIX;
42 \Log::debug('Initialised Memcached session');
43 }
44 }
45
46 47 48 49 50 51 52 53
54 static function MemcachedSession() {
55 return new MemcachedSession();
56 }
57
58 }