Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Memory.php
Go to the documentation of this file.
1 <?php
23 #require_once 'Zend/Memory/Manager.php';
24 
26 #require_once 'Zend/Memory/Value.php';
27 
29 #require_once 'Zend/Memory/Container.php';
30 
32 #require_once 'Zend/Cache.php';
33 
41 {
50  public static function factory($backend, $backendOptions = array())
51  {
52  if (strcasecmp($backend, 'none') == 0) {
53  return new Zend_Memory_Manager();
54  }
55 
56  // Look through available backendsand
57  // (that allows to specify it in any case)
58  $backendIsFound = false;
59  foreach (Zend_Cache::$standardBackends as $zendCacheBackend) {
60  if (strcasecmp($backend, $zendCacheBackend) == 0) {
61  $backend = $zendCacheBackend;
62  $backendIsFound = true;
63  break;
64  }
65  }
66 
67  if (!$backendIsFound) {
68  #require_once 'Zend/Memory/Exception.php';
69  throw new Zend_Memory_Exception("Incorrect backend ($backend)");
70  }
71 
72  $backendClass = 'Zend_Cache_Backend_' . $backend;
73 
74  // For perfs reasons, we do not use the Zend_Loader::loadClass() method
75  // (security controls are explicit)
76  #require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
77 
78  $backendObject = new $backendClass($backendOptions);
79 
80  return new Zend_Memory_Manager($backendObject);
81  }
82 }
static factory($backend, $backendOptions=array())
Definition: Memory.php:50
static $standardBackends
Definition: Cache.php:43