See Release Notes
Long Term Support Release
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Collection\Memory; 4 5 use DateInterval; 6 use Psr\SimpleCache\CacheInterface; 7 8 /** 9 * This is the default implementation for in-memory cell collection. 10 * 11 * Alternatives implementation should leverage off-memory, non-volatile storage 12 * to reduce overall memory usage. 13 */ 14 class SimpleCache1 implements CacheInterface 15 { 16 /** 17 * @var array Cell Cache 18 */ 19 private $cache = []; 20 21 /** 22 * @return bool 23 */ 24 public function clear() 25 { 26 $this->cache = []; 27 28 return true; 29 } 30 31 /** 32 * @param string $key 33 * 34 * @return bool 35 */ 36 public function delete($key) 37 { 38 unset($this->cache[$key]); 39 40 return true; 41 } 42 43 /** 44 * @param iterable $keys 45 * 46 * @return bool 47 */ 48 public function deleteMultiple($keys) 49 { 50 foreach ($keys as $key) { 51 $this->delete($key); 52 } 53 54 return true; 55 } 56 57 /** 58 * @param string $key 59 * @param mixed $default 60 * 61 * @return mixed 62 */ 63 public function get($key, $default = null) 64 { 65 if ($this->has($key)) { 66 return $this->cache[$key]; 67 } 68 69 return $default; 70 } 71 72 /** 73 * @param iterable $keys 74 * @param mixed $default 75 * 76 * @return iterable 77 */ 78 public function getMultiple($keys, $default = null) 79 { 80 $results = []; 81 foreach ($keys as $key) { 82 $results[$key] = $this->get($key, $default); 83 } 84 85 return $results; 86 } 87 88 /** 89 * @param string $key 90 * 91 * @return bool 92 */ 93 public function has($key) 94 { 95 return array_key_exists($key, $this->cache); 96 } 97 98 /** 99 * @param string $key 100 * @param mixed $value 101 * @param null|DateInterval|int $ttl 102 * 103 * @return bool 104 */ 105 public function set($key, $value, $ttl = null) 106 { 107 $this->cache[$key] = $value; 108 109 return true; 110 } 111 112 /** 113 * @param iterable $values 114 * @param null|DateInterval|int $ttl 115 * 116 * @return bool 117 */ 118 public function setMultiple($values, $ttl = null) 119 { 120 foreach ($values as $key => $value) { 121 $this->set($key, $value); 122 } 123 124 return true; 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body