1 | <?php |
||
40 | class DesarrollaCacheFactory implements FactoryInterface |
||
41 | { |
||
42 | /* @const DEFAULT_TTL */ |
||
43 | const DEFAULT_TTL = 3600; |
||
44 | /* @const DEFAULT_LIMIT */ |
||
45 | const DEFAULT_LIMIT = 1000; |
||
46 | |||
47 | /* @var array */ |
||
48 | protected $config; |
||
49 | |||
50 | /** |
||
51 | * @param string|null $configFile |
||
52 | * @param array $configArray |
||
53 | */ |
||
54 | 1 | public function __construct($configFile = null, array $configArray = []) |
|
55 | { |
||
56 | // Default config from distribution |
||
57 | 1 | if (null === $configFile) { |
|
58 | 1 | $configFile = __DIR__.'/../../../config/config.php'; |
|
59 | 1 | } |
|
60 | |||
61 | 1 | $config = include $configFile; |
|
62 | |||
63 | 1 | $this->config = array_merge($config, $configArray); |
|
64 | 1 | } |
|
65 | |||
66 | /** |
||
67 | * @inheritdoc |
||
68 | */ |
||
69 | 1 | public function make() |
|
73 | |||
74 | /** |
||
75 | * Make the driver based on given config |
||
76 | * |
||
77 | * @return null|\Desarrolla2\Cache\Adapter\AdapterInterface |
||
78 | * |
||
79 | * @throws DriverNotFoundException |
||
80 | * @throws InvalidConfigException |
||
81 | */ |
||
82 | 1 | protected function getDriver() |
|
104 | |||
105 | /** |
||
106 | * Create NotCache driver |
||
107 | * |
||
108 | * @return NotCache |
||
109 | */ |
||
110 | 1 | protected function createNotcacheDriver() |
|
114 | |||
115 | /** |
||
116 | * Create File driver |
||
117 | * |
||
118 | * @return File |
||
119 | */ |
||
120 | protected function createFileDriver() |
||
124 | |||
125 | /** |
||
126 | * Create APC driver |
||
127 | * |
||
128 | * @return Apc |
||
129 | */ |
||
130 | protected function createApcDriver() |
||
134 | |||
135 | /** |
||
136 | * Create Memory driver |
||
137 | * |
||
138 | * @return Memory |
||
139 | * @throws \Desarrolla2\Cache\Adapter\MemoryCacheException |
||
140 | */ |
||
141 | protected function createMemoryDriver() |
||
151 | |||
152 | /** |
||
153 | * Create Mongo driver |
||
154 | * |
||
155 | * @return Mongo |
||
156 | */ |
||
157 | protected function createMongoDriver() |
||
161 | |||
162 | /** |
||
163 | * Create MySQL driver |
||
164 | * |
||
165 | * @return MySQL |
||
166 | */ |
||
167 | protected function createMysqlDriver() |
||
176 | |||
177 | /** |
||
178 | * Create Redis driver |
||
179 | * |
||
180 | * @return Redis |
||
181 | */ |
||
182 | protected function createRedisDriver() |
||
186 | |||
187 | /** |
||
188 | * Create MemCache driver |
||
189 | * |
||
190 | * @return MemCache |
||
191 | */ |
||
192 | protected function createMemcacheDriver() |
||
196 | } |
||
197 |