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

Static Public Member Functions

static factory ($frontend, $backend, $frontendOptions=array(), $backendOptions=array(), $customFrontendNaming=false, $customBackendNaming=false, $autoload=false)
 
static _makeBackend ($backend, $backendOptions, $customBackendNaming=false, $autoload=false)
 
static _makeFrontend ($frontend, $frontendOptions=array(), $customFrontendNaming=false, $autoload=false)
 
static throwException ($msg, Exception $e=null)
 

Data Fields

const CLEANING_MODE_ALL = 'all'
 
const CLEANING_MODE_OLD = 'old'
 
const CLEANING_MODE_MATCHING_TAG = 'matchingTag'
 
const CLEANING_MODE_NOT_MATCHING_TAG = 'notMatchingTag'
 
const CLEANING_MODE_MATCHING_ANY_TAG = 'matchingAnyTag'
 

Static Public Attributes

static $standardFrontends = array('Core', 'Output', 'Class', 'File', 'Function', 'Page')
 
static $standardBackends
 
static $standardExtendedBackends = array('File', 'Apc', 'TwoLevels', 'Memcached', 'Libmemcached', 'Sqlite', 'WinCache')
 
static $availableFrontends = array('Core', 'Output', 'Class', 'File', 'Function', 'Page')
 
static $availableBackends = array('File', 'Sqlite', 'Memcached', 'Libmemcached', 'Apc', 'ZendPlatform', 'Xcache', 'WinCache', 'TwoLevels')
 

Static Protected Member Functions

static _normalizeName ($name)
 

Detailed Description

Definition at line 28 of file Cache.php.

Member Function Documentation

◆ _makeBackend()

static _makeBackend (   $backend,
  $backendOptions,
  $customBackendNaming = false,
  $autoload = false 
)
static

Backend Constructor

Parameters
string$backend
array$backendOptions
boolean$customBackendNaming
boolean$autoload
Returns
Zend_Cache_Backend

Definition at line 124 of file Cache.php.

125  {
126  if (!$customBackendNaming) {
127  $backend = self::_normalizeName($backend);
128  }
129  if (in_array($backend, Zend_Cache::$standardBackends)) {
130  // we use a standard backend
131  $backendClass = 'Zend_Cache_Backend_' . $backend;
132  // security controls are explicit
133  #require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
134  } else {
135  // we use a custom backend
136  if (!preg_match('~^[\w\\\\]+$~D', $backend)) {
137  Zend_Cache::throwException("Invalid backend name [$backend]");
138  }
139  if (!$customBackendNaming) {
140  // we use this boolean to avoid an API break
141  $backendClass = 'Zend_Cache_Backend_' . $backend;
142  } else {
143  $backendClass = $backend;
144  }
145  if (!$autoload) {
146  $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
147  if (!(self::_isReadable($file))) {
148  self::throwException("file $file not found in include_path");
149  }
150  #require_once $file;
151  }
152  }
153  return new $backendClass($backendOptions);
154  }
static $standardBackends
Definition: Cache.php:43
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
static _normalizeName($name)
Definition: Cache.php:218

◆ _makeFrontend()

static _makeFrontend (   $frontend,
  $frontendOptions = array(),
  $customFrontendNaming = false,
  $autoload = false 
)
static

Frontend Constructor

Parameters
string$frontend
array$frontendOptions
boolean$customFrontendNaming
boolean$autoload
Returns
Zend_Cache_Core|Zend_Cache_Frontend

Definition at line 165 of file Cache.php.

166  {
167  if (!$customFrontendNaming) {
168  $frontend = self::_normalizeName($frontend);
169  }
170  if (in_array($frontend, self::$standardFrontends)) {
171  // we use a standard frontend
172  // For perfs reasons, with frontend == 'Core', we can interact with the Core itself
173  $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend;
174  // security controls are explicit
175  #require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
176  } else {
177  // we use a custom frontend
178  if (!preg_match('~^[\w\\\\]+$~D', $frontend)) {
179  Zend_Cache::throwException("Invalid frontend name [$frontend]");
180  }
181  if (!$customFrontendNaming) {
182  // we use this boolean to avoid an API break
183  $frontendClass = 'Zend_Cache_Frontend_' . $frontend;
184  } else {
185  $frontendClass = $frontend;
186  }
187  if (!$autoload) {
188  $file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
189  if (!(self::_isReadable($file))) {
190  self::throwException("file $file not found in include_path");
191  }
192  #require_once $file;
193  }
194  }
195  return new $frontendClass($frontendOptions);
196  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
static _normalizeName($name)
Definition: Cache.php:218

◆ _normalizeName()

static _normalizeName (   $name)
staticprotected

Normalize frontend and backend names to allow multiple words TitleCased

Parameters
string$nameName to normalize
Returns
string

Definition at line 218 of file Cache.php.

219  {
220  $name = ucfirst(strtolower($name));
221  $name = str_replace(array('-', '_', '.'), ' ', $name);
222  $name = ucwords($name);
223  $name = str_replace(' ', '', $name);
224  if (stripos($name, 'ZendServer') === 0) {
225  $name = 'ZendServer_' . substr($name, strlen('ZendServer'));
226  }
227 
228  return $name;
229  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ factory()

static factory (   $frontend,
  $backend,
  $frontendOptions = array(),
  $backendOptions = array(),
  $customFrontendNaming = false,
  $customBackendNaming = false,
  $autoload = false 
)
static

Factory

Parameters
mixed$frontendfrontend name (string) or Zend_Cache_Frontend_ object
mixed$backendbackend name (string) or Zend_Cache_Backend_ object
array$frontendOptionsassociative array of options for the corresponding frontend constructor
array$backendOptionsassociative array of options for the corresponding backend constructor
boolean$customFrontendNamingif true, the frontend argument is used as a complete class name ; if false, the frontend argument is used as the end of "Zend_Cache_Frontend_[...]" class name
boolean$customBackendNamingif true, the backend argument is used as a complete class name ; if false, the backend argument is used as the end of "Zend_Cache_Backend_[...]" class name
boolean$autoloadif true, there will no require_once for backend and frontend (useful only for custom backends/frontends)
Exceptions
Zend_Cache_Exception
Returns
Zend_Cache_Core|Zend_Cache_Frontend

Definition at line 91 of file Cache.php.

92  {
93  if (is_string($backend)) {
94  $backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
95  } else {
96  if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
97  $backendObject = $backend;
98  } else {
99  self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
100  }
101  }
102  if (is_string($frontend)) {
103  $frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, $autoload);
104  } else {
105  if (is_object($frontend)) {
106  $frontendObject = $frontend;
107  } else {
108  self::throwException('frontend must be a frontend name (string) or an object');
109  }
110  }
111  $frontendObject->setBackend($backendObject);
112  return $frontendObject;
113  }
static _makeFrontend($frontend, $frontendOptions=array(), $customFrontendNaming=false, $autoload=false)
Definition: Cache.php:165
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
static _makeBackend($backend, $backendOptions, $customBackendNaming=false, $autoload=false)
Definition: Cache.php:124

◆ throwException()

static throwException (   $msg,
Exception  $e = null 
)
static

Throw an exception

Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic

Parameters
string$msgMessage for the exception
Exceptions
Zend_Cache_Exception

Definition at line 205 of file Cache.php.

206  {
207  // For perfs reasons, we use this dynamic inclusion
208  #require_once 'Zend/Cache/Exception.php';
209  throw new Zend_Cache_Exception($msg, 0, $e);
210  }

Field Documentation

◆ $availableBackends

$availableBackends = array('File', 'Sqlite', 'Memcached', 'Libmemcached', 'Apc', 'ZendPlatform', 'Xcache', 'WinCache', 'TwoLevels')
static

Definition at line 67 of file Cache.php.

◆ $availableFrontends

$availableFrontends = array('Core', 'Output', 'Class', 'File', 'Function', 'Page')
static

Definition at line 59 of file Cache.php.

◆ $standardBackends

$standardBackends
static
Initial value:
= array('File', 'Sqlite', 'Memcached', 'Libmemcached', 'Apc', 'ZendPlatform',
'Xcache', 'TwoLevels', 'WinCache', 'ZendServer_Disk', 'ZendServer_ShMem')

Definition at line 43 of file Cache.php.

◆ $standardExtendedBackends

$standardExtendedBackends = array('File', 'Apc', 'TwoLevels', 'Memcached', 'Libmemcached', 'Sqlite', 'WinCache')
static

Definition at line 51 of file Cache.php.

◆ $standardFrontends

$standardFrontends = array('Core', 'Output', 'Class', 'File', 'Function', 'Page')
static

Definition at line 36 of file Cache.php.

◆ CLEANING_MODE_ALL

const CLEANING_MODE_ALL = 'all'

Consts for clean() method

Definition at line 72 of file Cache.php.

◆ CLEANING_MODE_MATCHING_ANY_TAG

const CLEANING_MODE_MATCHING_ANY_TAG = 'matchingAnyTag'

Definition at line 76 of file Cache.php.

◆ CLEANING_MODE_MATCHING_TAG

const CLEANING_MODE_MATCHING_TAG = 'matchingTag'

Definition at line 74 of file Cache.php.

◆ CLEANING_MODE_NOT_MATCHING_TAG

const CLEANING_MODE_NOT_MATCHING_TAG = 'notMatchingTag'

Definition at line 75 of file Cache.php.

◆ CLEANING_MODE_OLD

const CLEANING_MODE_OLD = 'old'

Definition at line 73 of file Cache.php.


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