-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit.php
More file actions
55 lines (50 loc) · 1.49 KB
/
Init.php
File metadata and controls
55 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
class Init
{
private static $db = null;
private static $mongodb = null;
private static $dbConfig =null;
private static $mongodbConfig =null;
private static $cacheConfig =null;
private static $cache = null;
public static $Config = null;
public static $Router = null;
function __construct($param)
{
}
public static function db($db=0){
if(empty(self::$dbConfig)){
self::$dbConfig=self::$Config['mysql'][$db];
}
if(empty(self::$db)){
self::$db=\Db\MysqlDb::Prepare(self::$dbConfig);
}
return self::$db;
}
public static function mongodb($db=0){
if(empty(self::$mongodbConfig)){
self::$mongodbConfig=self::$Config['mongodb'][$db];
}
if(empty(self::$mongodb)){
self::$mongodb=\Db\MongoDB::Prepare(self::$mongodbConfig);
}
return self::$mongodb;
}
public static function cache($cache_type='memcache',$cache_id=0){
if(empty($cacheConfig)){
$cacheConfig=self::$Config[$cache_type][$cache_id];
}
if(empty(self::$cache)){
switch($cache_type)
{
case 'memcache':
return self::$cache=new \Cache\Memcache($cacheConfig);
break;
case 'redis':
return self::$cache=new \Cache\Redis($cacheConfig);
break;
}
}
return self::$cache;
}
}