1
1
<?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: Administrator
5
- * Date: 2018/10/24
6
- * Time: 18:00
7
- */
2
+ declare (strict_types=1 );
8
3
9
- namespace rabbit \ cache ;
4
+ namespace Rabbit \ Cache ;
10
5
11
6
use Psr \SimpleCache \CacheInterface ;
12
- use rabbit \parser \ParserInterface ;
7
+ use Psr \SimpleCache \InvalidArgumentException ;
8
+ use Rabbit \Parser \ParserInterface ;
13
9
14
10
/**
15
11
* Class Cache
@@ -20,20 +16,22 @@ class Cache implements CacheInterface
20
16
/**
21
17
* @var string
22
18
*/
23
- private $ driver = 'memory ' ;
19
+ private string $ driver = 'memory ' ;
24
20
25
21
/**
26
22
* @var array
27
23
*/
28
- private $ drivers = [];
24
+ private array $ drivers = [];
29
25
30
26
/**
31
27
* @var ParserInterface|null
32
28
*/
33
- private $ serializer = null ;
29
+ private ? ParserInterface $ serializer = null ;
34
30
35
31
/**
36
32
* Cache constructor.
33
+ * @param array $drivers
34
+ * @param ParserInterface|null $serializer
37
35
*/
38
36
public function __construct (array $ drivers , ParserInterface $ serializer = null )
39
37
{
@@ -62,7 +60,7 @@ public function getDriver(string $driver = null): CacheInterface
62
60
* @param int $duration
63
61
* @param string $driver
64
62
* @return mixed
65
- * @throws \Psr\SimpleCache\ InvalidArgumentException
63
+ * @throws InvalidArgumentException
66
64
*/
67
65
public function cache (string $ key , callable $ function , int $ duration = 0 , string $ driver = 'memory ' )
68
66
{
@@ -87,7 +85,7 @@ private function getDrivers(): array
87
85
* @param string $key
88
86
* @param null $default
89
87
* @return mixed
90
- * @throws \Psr\SimpleCache\ InvalidArgumentException
88
+ * @throws InvalidArgumentException
91
89
*/
92
90
public function get ($ key , $ default = null )
93
91
{
@@ -99,7 +97,7 @@ public function get($key, $default = null)
99
97
* @param mixed $value
100
98
* @param null $ttl
101
99
* @return bool
102
- * @throws \Psr\SimpleCache\ InvalidArgumentException
100
+ * @throws InvalidArgumentException
103
101
*/
104
102
public function set ($ key , $ value , $ ttl = null )
105
103
{
@@ -109,7 +107,7 @@ public function set($key, $value, $ttl = null)
109
107
/**
110
108
* @param string $key
111
109
* @return bool
112
- * @throws \Psr\SimpleCache\ InvalidArgumentException
110
+ * @throws InvalidArgumentException
113
111
*/
114
112
public function delete ($ key )
115
113
{
@@ -128,7 +126,7 @@ public function clear()
128
126
* @param iterable $keys
129
127
* @param null $default
130
128
* @return iterable
131
- * @throws \Psr\SimpleCache\ InvalidArgumentException
129
+ * @throws InvalidArgumentException
132
130
*/
133
131
public function getMultiple ($ keys , $ default = null )
134
132
{
@@ -139,7 +137,7 @@ public function getMultiple($keys, $default = null)
139
137
* @param iterable $values
140
138
* @param null $ttl
141
139
* @return bool
142
- * @throws \Psr\SimpleCache\ InvalidArgumentException
140
+ * @throws InvalidArgumentException
143
141
*/
144
142
public function setMultiple ($ values , $ ttl = null )
145
143
{
@@ -149,7 +147,7 @@ public function setMultiple($values, $ttl = null)
149
147
/**
150
148
* @param iterable $keys
151
149
* @return bool
152
- * @throws \Psr\SimpleCache\ InvalidArgumentException
150
+ * @throws InvalidArgumentException
153
151
*/
154
152
public function deleteMultiple ($ keys )
155
153
{
@@ -159,7 +157,7 @@ public function deleteMultiple($keys)
159
157
/**
160
158
* @param string $key
161
159
* @return bool
162
- * @throws \Psr\SimpleCache\ InvalidArgumentException
160
+ * @throws InvalidArgumentException
163
161
*/
164
162
public function has ($ key )
165
163
{
0 commit comments