Blame view

vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php 1.46 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  <?php
  
  namespace PhpOffice\PhpSpreadsheet\Collection;
  
  use Psr\SimpleCache\CacheInterface;
  
  /**
   * This is the default implementation for in-memory cell collection.
   *
   * Alternatives implementation should leverage off-memory, non-volatile storage
   * to reduce overall memory usage.
   */
  class Memory implements CacheInterface
  {
      private $cache = [];
  
      public function clear()
      {
          $this->cache = [];
  
          return true;
      }
  
      public function delete($key)
      {
          unset($this->cache[$key]);
  
          return true;
      }
  
      public function deleteMultiple($keys)
      {
          foreach ($keys as $key) {
              $this->delete($key);
          }
  
          return true;
      }
  
      public function get($key, $default = null)
      {
          if ($this->has($key)) {
              return $this->cache[$key];
          }
  
          return $default;
      }
  
      public function getMultiple($keys, $default = null)
      {
          $results = [];
          foreach ($keys as $key) {
              $results[$key] = $this->get($key, $default);
          }
  
          return $results;
      }
  
      public function has($key)
      {
          return array_key_exists($key, $this->cache);
      }
  
      public function set($key, $value, $ttl = null)
      {
          $this->cache[$key] = $value;
  
          return true;
      }
  
      public function setMultiple($values, $ttl = null)
      {
          foreach ($values as $key => $value) {
              $this->set($key, $value);
          }
  
          return true;
      }
  }