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 / SimpleCache1.php

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

91 lines 1.5 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 TablePress\Psr\SimpleCache\CacheInterface;
6
7 /**
8 * This is the default implementation for in-memory cell collection.
9 *
10 * Alternative implementation should leverage off-memory, non-volatile storage
11 * to reduce overall memory usage.
12 *
13 * Either SimpleCache1 or SimpleCache3, but not both, may be used.
14 * For code coverage testing, it will always be SimpleCache3.
15 *
16 * @codeCoverageIgnore
17 */
18 class SimpleCache1 implements CacheInterface
19 {
20 /**
21 * @var array Cell Cache
22 */
23 private array $cache = [];
24
25 public function clear(): bool
26 {
27 $this->cache = [];
28
29 return true;
30 }
31
32 public function delete($key): bool
33 {
34 unset($this->cache[$key]);
35
36 return true;
37 }
38
39 public function deleteMultiple($keys): bool
40 {
41 foreach ($keys as $key) {
42 $this->delete($key);
43 }
44
45 return true;
46 }
47
48 /**
49 * @return mixed
50 */
51 public function get($key, $default = null)
52 {
53 if ($this->has($key)) {
54 return $this->cache[$key];
55 }
56
57 return $default;
58 }
59
60 public function getMultiple($keys, $default = null): iterable
61 {
62 $results = [];
63 foreach ($keys as $key) {
64 $results[$key] = $this->get($key, $default);
65 }
66
67 return $results;
68 }
69
70 public function has($key): bool
71 {
72 return array_key_exists($key, $this->cache);
73 }
74
75 public function set($key, $value, $ttl = null): bool
76 {
77 $this->cache[$key] = $value;
78
79 return true;
80 }
81
82 public function setMultiple($values, $ttl = null): bool
83 {
84 foreach ($values as $key => $value) {
85 $this->set($key, $value);
86 }
87
88 return true;
89 }
90 }
91