1
|
|
|
<?php namespace Comodojo\Cache\Providers; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Cache\Components\IdTrait; |
4
|
|
|
use \Comodojo\Cache\Components\NamespaceTrait; |
5
|
|
|
use \Comodojo\Cache\Components\StatusSwitchTrait; |
6
|
|
|
use \Comodojo\Cache\Components\TimeTrait; |
7
|
|
|
use \Comodojo\Cache\Components\TtlTrait; |
8
|
|
|
use \Comodojo\Cache\Components\LoggerTrait; |
9
|
|
|
use \Comodojo\Cache\Components\ErrorStateTrait; |
10
|
|
|
use \Psr\Log\LoggerInterface; |
11
|
|
|
use \Comodojo\Exception\CacheException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Cache controller |
15
|
|
|
* |
16
|
|
|
* @package Comodojo Spare Parts |
17
|
|
|
* @author Marco Giovinazzi <[email protected]> |
18
|
|
|
* @license MIT |
19
|
|
|
* |
20
|
|
|
* LICENSE: |
21
|
|
|
* |
22
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
23
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
24
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
25
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
26
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
27
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
28
|
|
|
* THE SOFTWARE. |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
abstract class AbstractProvider implements ProviderInterface { |
32
|
|
|
|
33
|
|
|
use IdTrait; |
34
|
|
|
use NamespaceTrait; |
35
|
|
|
use StatusSwitchTrait; |
36
|
|
|
use TimeTrait; |
37
|
|
|
use TtlTrait; |
38
|
|
|
use LoggerTrait; |
39
|
|
|
use ErrorStateTrait; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Class constructor |
43
|
|
|
* |
44
|
|
|
* @throws \Comodojo\Exception\CacheException |
45
|
|
|
*/ |
46
|
85 |
|
public function __construct(LoggerInterface $logger = null) { |
47
|
|
|
|
48
|
|
|
try { |
49
|
|
|
|
50
|
85 |
|
$this->setTime(); |
51
|
|
|
|
52
|
85 |
|
$this->setTtl(); |
53
|
|
|
|
54
|
85 |
|
$this->setCacheId(); |
55
|
|
|
|
56
|
85 |
|
$this->setLogger($logger); |
57
|
|
|
|
58
|
85 |
|
} catch (CacheException $ce) { |
59
|
|
|
|
60
|
|
|
throw $ce; |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
85 |
|
} |
65
|
|
|
|
66
|
1 |
|
public function getType() { |
67
|
|
|
|
68
|
1 |
|
return get_class($this); |
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
abstract public function set($name, $data, $ttl = null); |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
abstract public function get($name); |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritdoc} |
84
|
|
|
*/ |
85
|
|
|
abstract public function delete($name = null); |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* {@inheritdoc} |
89
|
|
|
*/ |
90
|
|
|
abstract public function flush(); |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
abstract public function status(); |
96
|
|
|
|
97
|
|
|
} |
98
|
|
|
|