Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Zend_Cache_Manager Class Reference

Public Member Functions

 setCache ($name, Zend_Cache_Core $cache)
 
 hasCache ($name)
 
 getCache ($name)
 
 getCaches ()
 
 setCacheTemplate ($name, $options)
 
 hasCacheTemplate ($name)
 
 getCacheTemplate ($name)
 
 setTemplateOptions ($name, $options)
 

Data Fields

const PAGECACHE = 'page'
 
const PAGETAGCACHE = 'pagetag'
 

Protected Member Functions

 _mergeOptions (array $current, array $options)
 

Protected Attributes

 $_caches = array()
 
 $_optionTemplates
 

Detailed Description

Definition at line 34 of file Manager.php.

Member Function Documentation

◆ _mergeOptions()

_mergeOptions ( array  $current,
array  $options 
)
protected

Simple method to merge two configuration arrays

Parameters
array$current
array$options
Returns
array

Definition at line 279 of file Manager.php.

280  {
281  if (isset($options['frontend']['name'])) {
282  $current['frontend']['name'] = $options['frontend']['name'];
283  }
284  if (isset($options['backend']['name'])) {
285  $current['backend']['name'] = $options['backend']['name'];
286  }
287  if (isset($options['frontend']['options'])) {
288  foreach ($options['frontend']['options'] as $key => $value) {
289  $current['frontend']['options'][$key] = $value;
290  }
291  }
292  if (isset($options['backend']['options'])) {
293  foreach ($options['backend']['options'] as $key => $value) {
294  $current['backend']['options'][$key] = $value;
295  }
296  }
297  if (isset($options['frontend']['customFrontendNaming'])) {
298  $current['frontend']['customFrontendNaming'] = $options['frontend']['customFrontendNaming'];
299  }
300  if (isset($options['backend']['customBackendNaming'])) {
301  $current['backend']['customBackendNaming'] = $options['backend']['customBackendNaming'];
302  }
303  if (isset($options['frontendBackendAutoload'])) {
304  $current['frontendBackendAutoload'] = $options['frontendBackendAutoload'];
305  }
306  return $current;
307  }
$value
Definition: gender.phtml:16

◆ getCache()

getCache (   $name)

Fetch the named cache object, or instantiate and return a cache object using a named configuration template

Parameters
string$name
Returns
Zend_Cache_Core

Definition at line 151 of file Manager.php.

152  {
153  if (isset($this->_caches[$name])) {
154  return $this->_caches[$name];
155  }
156  if (isset($this->_optionTemplates[$name])) {
157  if ($name == self::PAGECACHE
158  && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache'])
159  || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core)
160  ) {
161  $this->_optionTemplates[$name]['backend']['options']['tag_cache']
162  = $this->getCache(self::PAGETAGCACHE);
163  }
164 
165  $this->_caches[$name] = Zend_Cache::factory(
166  $this->_optionTemplates[$name]['frontend']['name'],
167  $this->_optionTemplates[$name]['backend']['name'],
168  isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(),
169  isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(),
170  isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false,
171  isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false,
172  isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false
173  );
174 
175  return $this->_caches[$name];
176  }
177  }
static factory($frontend, $backend, $frontendOptions=array(), $backendOptions=array(), $customFrontendNaming=false, $customBackendNaming=false, $autoload=false)
Definition: Cache.php:91
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getCaches()

getCaches ( )

Fetch all available caches

Returns
array An array of all available caches with it's names as key

Definition at line 184 of file Manager.php.

185  {
186  $caches = $this->_caches;
187  foreach ($this->_optionTemplates as $name => $tmp) {
188  if (!isset($caches[$name])) {
189  $caches[$name] = $this->getCache($name);
190  }
191  }
192  return $caches;
193  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getCacheTemplate()

getCacheTemplate (   $name)

Get the named configuration template

Parameters
string$name
Returns
array

Definition at line 237 of file Manager.php.

238  {
239  if (isset($this->_optionTemplates[$name])) {
240  return $this->_optionTemplates[$name];
241  }
242  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ hasCache()

hasCache (   $name)

Check if the Cache Manager contains the named cache object, or a named configuration template to lazy load the cache object

Parameters
string$name
Returns
bool

Definition at line 134 of file Manager.php.

135  {
136  if (isset($this->_caches[$name])
137  || $this->hasCacheTemplate($name)
138  ) {
139  return true;
140  }
141  return false;
142  }
hasCacheTemplate($name)
Definition: Manager.php:223
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ hasCacheTemplate()

hasCacheTemplate (   $name)

Check if the named configuration template

Parameters
string$name
Returns
bool

Definition at line 223 of file Manager.php.

224  {
225  if (isset($this->_optionTemplates[$name])) {
226  return true;
227  }
228  return false;
229  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setCache()

setCache (   $name,
Zend_Cache_Core  $cache 
)

Set a new cache for the Cache Manager to contain

Parameters
string$name
Zend_Cache_Core$cache
Returns
Zend_Cache_Manager

Definition at line 121 of file Manager.php.

122  {
123  $this->_caches[$name] = $cache;
124  return $this;
125  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setCacheTemplate()

setCacheTemplate (   $name,
  $options 
)

Set a named configuration template from which a cache object can later be lazy loaded

Parameters
string$name
array$options
Returns
Zend_Cache_Manager
Exceptions
Zend_Cache_Exception

Definition at line 204 of file Manager.php.

205  {
206  if ($options instanceof Zend_Config) {
207  $options = $options->toArray();
208  } elseif (!is_array($options)) {
209  #require_once 'Zend/Cache/Exception.php';
210  throw new Zend_Cache_Exception('Options passed must be in'
211  . ' an associative array or instance of Zend_Config');
212  }
213  $this->_optionTemplates[$name] = $options;
214  return $this;
215  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setTemplateOptions()

setTemplateOptions (   $name,
  $options 
)

Pass an array containing changes to be applied to a named configuration template

Parameters
string$name
array$options
Returns
Zend_Cache_Manager
Exceptions
Zend_Cache_Exceptionfor invalid options format or if option templates do not have $name

Definition at line 254 of file Manager.php.

255  {
256  if ($options instanceof Zend_Config) {
257  $options = $options->toArray();
258  } elseif (!is_array($options)) {
259  #require_once 'Zend/Cache/Exception.php';
260  throw new Zend_Cache_Exception('Options passed must be in'
261  . ' an associative array or instance of Zend_Config');
262  }
263  if (!isset($this->_optionTemplates[$name])) {
264  throw new Zend_Cache_Exception('A cache configuration template'
265  . 'does not exist with the name "' . $name . '"');
266  }
267  $this->_optionTemplates[$name]
268  = $this->_mergeOptions($this->_optionTemplates[$name], $options);
269  return $this;
270  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_mergeOptions(array $current, array $options)
Definition: Manager.php:279
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ $_caches

$_caches = array()
protected

Definition at line 51 of file Manager.php.

◆ $_optionTemplates

$_optionTemplates
protected

Definition at line 59 of file Manager.php.

◆ PAGECACHE

const PAGECACHE = 'page'

Constant holding reserved name for default Page Cache

Definition at line 39 of file Manager.php.

◆ PAGETAGCACHE

const PAGETAGCACHE = 'pagetag'

Constant holding reserved name for default Page Tag Cache

Definition at line 44 of file Manager.php.


The documentation for this class was generated from the following file: