TYPO3 CMS  TYPO3_8-7
ClassInfoCache.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  private $level1Cache = [];
26 
30  private $level2Cache;
31 
35  public function __construct()
36  {
37  $this->initializeLevel2Cache();
38  }
39 
46  public function has($id)
47  {
48  return isset($this->level1Cache[$id]) || $this->level2Cache->has($id);
49  }
50 
57  public function get($id)
58  {
59  if (!isset($this->level1Cache[$id])) {
60  $this->level1Cache[$id] = $this->level2Cache->get($id);
61  }
62  return $this->level1Cache[$id];
63  }
64 
71  public function set($id, $value)
72  {
73  $this->level1Cache[$id] = $value;
74  $this->level2Cache->set($id, $value);
75  }
76 
80  private function initializeLevel2Cache()
81  {
82  $this->level2Cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('extbase_object');
83  }
84 }
static makeInstance($className,... $constructorArguments)