2
2
3
3
namespace PhpOffice \PhpSpreadsheet \Collection ;
4
4
5
+ use DateInterval ;
5
6
use Psr \SimpleCache \CacheInterface ;
6
7
7
8
/**
@@ -14,20 +15,33 @@ class Memory implements CacheInterface
14
15
{
15
16
private $ cache = [];
16
17
18
+ /**
19
+ * @return bool
20
+ */
17
21
public function clear ()
18
22
{
19
23
$ this ->cache = [];
20
24
21
25
return true ;
22
26
}
23
27
28
+ /**
29
+ * @param string $key
30
+ *
31
+ * @return bool
32
+ */
24
33
public function delete ($ key )
25
34
{
26
35
unset($ this ->cache [$ key ]);
27
36
28
37
return true ;
29
38
}
30
39
40
+ /**
41
+ * @param iterable $keys
42
+ *
43
+ * @return bool
44
+ */
31
45
public function deleteMultiple ($ keys )
32
46
{
33
47
foreach ($ keys as $ key ) {
@@ -37,6 +51,12 @@ public function deleteMultiple($keys)
37
51
return true ;
38
52
}
39
53
54
+ /**
55
+ * @param string $key
56
+ * @param mixed $default
57
+ *
58
+ * @return mixed
59
+ */
40
60
public function get ($ key , $ default = null )
41
61
{
42
62
if ($ this ->has ($ key )) {
@@ -46,6 +66,12 @@ public function get($key, $default = null)
46
66
return $ default ;
47
67
}
48
68
69
+ /**
70
+ * @param iterable $keys
71
+ * @param mixed $default
72
+ *
73
+ * @return iterable
74
+ */
49
75
public function getMultiple ($ keys , $ default = null )
50
76
{
51
77
$ results = [];
@@ -56,18 +82,36 @@ public function getMultiple($keys, $default = null)
56
82
return $ results ;
57
83
}
58
84
85
+ /**
86
+ * @param string $key
87
+ *
88
+ * @return bool
89
+ */
59
90
public function has ($ key )
60
91
{
61
92
return array_key_exists ($ key , $ this ->cache );
62
93
}
63
94
95
+ /**
96
+ * @param string $key
97
+ * @param mixed $value
98
+ * @param null|DateInterval|int $ttl
99
+ *
100
+ * @return bool
101
+ */
64
102
public function set ($ key , $ value , $ ttl = null )
65
103
{
66
104
$ this ->cache [$ key ] = $ value ;
67
105
68
106
return true ;
69
107
}
70
108
109
+ /**
110
+ * @param iterable $values
111
+ * @param null|DateInterval|int $ttl
112
+ *
113
+ * @return bool
114
+ */
71
115
public function setMultiple ($ values , $ ttl = null )
72
116
{
73
117
foreach ($ values as $ key => $ value ) {
0 commit comments