Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Zend_Cache_Frontend_File Class Reference
Inheritance diagram for Zend_Cache_Frontend_File:
Zend_Cache_Core

Public Member Functions

 __construct (array $options=array())
 
 setMasterFiles (array $masterFiles)
 
 setMasterFile ($masterFile)
 
 setOption ($name, $value)
 
 load ($id, $doNotTestCacheValidity=false, $doNotUnserialize=false)
 
 test ($id)
 
- Public Member Functions inherited from Zend_Cache_Core
 __construct ($options=array())
 
 setConfig (Zend_Config $config)
 
 setBackend (Zend_Cache_Backend $backendObject)
 
 getBackend ()
 
 setOption ($name, $value)
 
 getOption ($name)
 
 setLifetime ($newLifetime)
 
 load ($id, $doNotTestCacheValidity=false, $doNotUnserialize=false)
 
 test ($id)
 
 save ($data, $id=null, $tags=array(), $specificLifetime=false, $priority=8)
 
 remove ($id)
 
 clean ($mode='all', $tags=array())
 
 getIdsMatchingTags ($tags=array())
 
 getIdsNotMatchingTags ($tags=array())
 
 getIdsMatchingAnyTags ($tags=array())
 
 getIds ()
 
 getTags ()
 
 getFillingPercentage ()
 
 getMetadatas ($id)
 
 touch ($id, $extraLifetime)
 

Data Fields

const MODE_AND = 'AND'
 
const MODE_OR = 'OR'
 
- Data Fields inherited from Zend_Cache_Core
const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'
 
const BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'
 

Protected Attributes

 $_specificOptions
 
- Protected Attributes inherited from Zend_Cache_Core
 $_backend = null
 
 $_options
 
 $_specificOptions = array()
 
 $_extendedBackend = false
 
 $_backendCapabilities = array()
 

Additional Inherited Members

- Protected Member Functions inherited from Zend_Cache_Core
 _validateIdOrTag ($string)
 
 _validateTagsArray ($tags)
 
 _loggerSanity ()
 
 _log ($message, $priority=4)
 
 _id ($id)
 
- Static Protected Attributes inherited from Zend_Cache_Core
static $_directivesList = array('lifetime', 'logging', 'logger')
 

Detailed Description

Definition at line 36 of file File.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $options = array())

Constructor

Parameters
array$optionsAssociative array of options
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 89 of file File.php.

90  {
91  foreach ($options as $name => $value) {
92  $this->setOption($name, $value);
93  }
94  if (!isset($this->_specificOptions['master_files'])) {
95  Zend_Cache::throwException('master_files option must be set');
96  }
97  }
$value
Definition: gender.phtml:16
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
setOption($name, $value)
Definition: File.php:156
if(!isset($_GET['name'])) $name
Definition: log.php:14

Member Function Documentation

◆ load()

load (   $id,
  $doNotTestCacheValidity = false,
  $doNotUnserialize = false 
)

Test if a cache is available for the given id and (if yes) return it (false else)

Parameters
string$idCache id
boolean$doNotTestCacheValidityIf set to true, the cache validity won't be tested
boolean$doNotUnserializeDo not serialize (even if automatic_serialization is true) => for internal use
Returns
mixed|false Cached datas

Definition at line 175 of file File.php.

176  {
177  if (!$doNotTestCacheValidity) {
178  if ($this->test($id)) {
179  return parent::load($id, true, $doNotUnserialize);
180  }
181  return false;
182  }
183  return parent::load($id, true, $doNotUnserialize);
184  }
$id
Definition: fieldset.phtml:14

◆ setMasterFile()

setMasterFile (   $masterFile)

Change the master_file option

To keep the compatibility

Deprecated:
Parameters
string$masterFilethe complete path and name of the master file

Definition at line 141 of file File.php.

142  {
143  $this->setMasterFiles(array($masterFile));
144  }
setMasterFiles(array $masterFiles)
Definition: File.php:104

◆ setMasterFiles()

setMasterFiles ( array  $masterFiles)

Change the master_files option

Parameters
array$masterFilesthe complete paths and name of the master files

Definition at line 104 of file File.php.

105  {
106  $this->_specificOptions['master_file'] = null; // to keep a compatibility
107  $this->_specificOptions['master_files'] = null;
108  $this->_masterFile_mtimes = array();
109 
110  clearstatcache();
111  $i = 0;
112  foreach ($masterFiles as $masterFile) {
113  if (file_exists($masterFile)) {
114  $mtime = filemtime($masterFile);
115  } else {
116  $mtime = false;
117  }
118 
119  if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) {
120  Zend_Cache::throwException('Unable to read master_file : ' . $masterFile);
121  }
122 
123  $this->_masterFile_mtimes[$i] = $mtime;
124  $this->_specificOptions['master_files'][$i] = $masterFile;
125  if ($i === 0) { // to keep a compatibility
126  $this->_specificOptions['master_file'] = $masterFile;
127  }
128 
129  $i++;
130  }
131  }
static throwException($msg, Exception $e=null)
Definition: Cache.php:205
$i
Definition: gallery.phtml:31

◆ setOption()

setOption (   $name,
  $value 
)

Public frontend to set an option

Just a wrapper to get a specific behaviour for master_file

Parameters
string$nameName of the option
mixed$valueValue of the option
Exceptions
Zend_Cache_Exception
Returns
void

Definition at line 156 of file File.php.

157  {
158  if ($name == 'master_file') {
159  $this->setMasterFile($value);
160  } else if ($name == 'master_files') {
161  $this->setMasterFiles($value);
162  } else {
163  parent::setOption($name, $value);
164  }
165  }
setMasterFile($masterFile)
Definition: File.php:141
setMasterFiles(array $masterFiles)
Definition: File.php:104
$value
Definition: gender.phtml:16
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ test()

test (   $id)

Test if a cache is available for the given id

Parameters
string$idCache id
Returns
int|false Last modified time of cache entry if it is available, false otherwise

Definition at line 192 of file File.php.

193  {
194  $lastModified = parent::test($id);
195  if ($lastModified) {
196  if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
197  // MODE_AND
198  foreach($this->_masterFile_mtimes as $masterFileMTime) {
199  if ($masterFileMTime) {
200  if ($lastModified > $masterFileMTime) {
201  return $lastModified;
202  }
203  }
204  }
205  } else {
206  // MODE_OR
207  $res = true;
208  foreach($this->_masterFile_mtimes as $masterFileMTime) {
209  if ($masterFileMTime) {
210  if ($lastModified <= $masterFileMTime) {
211  return false;
212  }
213  }
214  }
215  return $lastModified;
216  }
217  }
218  return false;
219  }
$id
Definition: fieldset.phtml:14

Field Documentation

◆ $_specificOptions

$_specificOptions
protected
Initial value:
= array(
'master_file' => null,
'master_files' => null,
'master_files_mode' => 'OR',
'ignore_missing_master_files' => false
)

Definition at line 66 of file File.php.

◆ MODE_AND

const MODE_AND = 'AND'

Consts for master_files_mode

Definition at line 42 of file File.php.

◆ MODE_OR

const MODE_OR = 'OR'

Definition at line 43 of file File.php.


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