1 | <?php |
||
15 | class CacheBuilder |
||
16 | { |
||
17 | /** |
||
18 | * @var CacheFactoryInterface |
||
19 | */ |
||
20 | private $factory; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $caches = []; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $withExceptions = true; |
||
31 | |||
32 | /** |
||
33 | * @var LoggerInterface |
||
34 | */ |
||
35 | private $logger = null; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | private $logLevel = LogLevel::ALERT; |
||
41 | |||
42 | /** |
||
43 | * CacheBuilder constructor. |
||
44 | * |
||
45 | * @param CacheFactoryInterface $cacheFactory |
||
46 | */ |
||
47 | 1 | public function __construct(CacheFactoryInterface $cacheFactory = null) |
|
51 | |||
52 | /** |
||
53 | * @return $this |
||
54 | */ |
||
55 | 1 | public function withoutExceptions() |
|
61 | |||
62 | /** |
||
63 | * Sets a logger to log exceptions |
||
64 | * |
||
65 | * @param LoggerInterface $logger |
||
66 | * @param string $logLevel |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | 1 | public function withLogging(LoggerInterface $logger, $logLevel = LogLevel::ALERT) |
|
77 | |||
78 | /** |
||
79 | * @param string $host |
||
80 | * @param int $port |
||
81 | * @param int $db |
||
82 | * @param float $timeOut |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | 1 | public function withRedisCacheFromParams($host = '127.0.0.1', $port = 6379, $db = 0, $timeOut = 0.0) |
|
92 | |||
93 | /** |
||
94 | * @return $this |
||
95 | */ |
||
96 | 1 | public function withArrayCache() |
|
102 | |||
103 | /** |
||
104 | * @param Redis $redis |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | 1 | public function withRedis(Redis $redis) |
|
114 | |||
115 | /** |
||
116 | * @param Cache $cache |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | 1 | public function withCache(Cache $cache) |
|
126 | |||
127 | /** |
||
128 | * @return Cache |
||
129 | */ |
||
130 | 1 | private function buildCache() |
|
143 | |||
144 | /** |
||
145 | * @return Cache |
||
146 | */ |
||
147 | 1 | public function build() |
|
157 | } |
||
158 |