PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Collection / Memory / SimpleCache3.php

SimpleCache3.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Collection/Memory/SimpleCache3.php

95 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Collection\Memory;
4
5 use DateInterval;
6 use TablePress\Psr\SimpleCache\CacheInterface;
7
8 /**
9 * This is the default implementation for in-memory cell collection.
10 *
11 * Alternative implementation should leverage off-memory, non-volatile storage
12 * to reduce overall memory usage.
13 */
14 class SimpleCache3 implements CacheInterface
15 {
16 private array $cache = [];
17
18 public function clear(): bool
19 {
20 $this->cache = [];
21
22 return true;
23 }
24
25 public function delete(string $key): bool
26 {
27 unset($this->cache[$key]);
28
29 return true;
30 }
31
32 public function deleteMultiple(iterable $keys): bool
33 {
34 foreach ($keys as $key) {
35 $this->delete($key);
36 }
37
38 return true;
39 }
40
41 /**
42 * @param mixed $default
43 * @return mixed
44 */
45 public function get(string $key, $default = null)
46 {
47 if ($this->has($key)) {
48 return $this->cache[$key];
49 }
50
51 return $default;
52 }
53
54 /**
55 * @param mixed $default
56 */
57 public function getMultiple(iterable $keys, $default = null): iterable
58 {
59 $results = [];
60 foreach ($keys as $key) {
61 $results[$key] = $this->get($key, $default);
62 }
63
64 return $results;
65 }
66
67 public function has(string $key): bool
68 {
69 return array_key_exists($key, $this->cache);
70 }
71
72 /**
73 * @param null|int|\DateInterval $ttl
74 * @param mixed $value
75 */
76 public function set(string $key, $value, $ttl = null): bool
77 {
78 $this->cache[$key] = $value;
79
80 return true;
81 }
82
83 /**
84 * @param null|int|\DateInterval $ttl
85 */
86 public function setMultiple(iterable $values, $ttl = null): bool
87 {
88 foreach ($values as $key => $value) {
89 $this->set($key, $value);
90 }
91
92 return true;
93 }
94 }
95