Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
Profiler Class Reference
Inheritance diagram for Profiler:
Bare FrontendInterface

Public Member Functions

 __construct (\Magento\Framework\Cache\FrontendInterface $frontend, $backendPrefixes=[])
 
 test ($identifier)
 
 load ($identifier)
 
 save ($data, $identifier, array $tags=[], $lifeTime=null)
 
 remove ($identifier)
 
 clean ($mode=\Zend_Cache::CLEANING_MODE_ALL, array $tags=[])
 
- Public Member Functions inherited from Bare
 __construct (\Magento\Framework\Cache\FrontendInterface $frontend)
 
 test ($identifier)
 
 load ($identifier)
 
 save ($data, $identifier, array $tags=[], $lifeTime=null)
 
 remove ($identifier)
 
 clean ($mode=\Zend_Cache::CLEANING_MODE_ALL, array $tags=[])
 
 getBackend ()
 
 getLowLevelFrontend ()
 

Protected Member Functions

 _getProfilerTags ($operation)
 
 _getBackendType ()
 
- Protected Member Functions inherited from Bare
 setFrontend (\Magento\Framework\Cache\FrontendInterface $frontend)
 
 _getFrontend ()
 

Detailed Description

Cache frontend decorator that performs profiling of cache operations

Definition at line 12 of file Profiler.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Cache\FrontendInterface  $frontend,
  $backendPrefixes = [] 
)
Parameters
\Magento\Framework\Cache\FrontendInterface$frontend
string[]$backendPrefixes Backend class prefixes to be striped for profiling informativeness

Definition at line 25 of file Profiler.php.

26  {
27  parent::__construct($frontend);
28  $this->_backendPrefixes = $backendPrefixes;
29  }

Member Function Documentation

◆ _getBackendType()

_getBackendType ( )
protected

Get short cache backend type name by striping known backend class prefixes

Returns
string

Definition at line 52 of file Profiler.php.

53  {
54  $result = get_class($this->getBackend());
55  foreach ($this->_backendPrefixes as $backendClassPrefix) {
56  if (substr($result, 0, strlen($backendClassPrefix)) == $backendClassPrefix) {
57  $result = substr($result, strlen($backendClassPrefix));
58  break;
59  }
60  }
61  return $result;
62  }

◆ _getProfilerTags()

_getProfilerTags (   $operation)
protected

Retrieve profiler tags that correspond to a cache operation

Parameters
string$operation
Returns
array

Definition at line 37 of file Profiler.php.

38  {
39  return [
40  'group' => 'cache',
41  'operation' => 'cache:' . $operation,
42  'frontend_type' => get_class($this->getLowLevelFrontend()),
43  'backend_type' => $this->_getBackendType()
44  ];
45  }

◆ clean()

clean (   $mode = \Zend_Cache::CLEANING_MODE_ALL,
array  $tags = [] 
)

{Clean cache records matching specified tags

Parameters
string$mode
array$tags
Returns
bool @api
}

Implements FrontendInterface.

Definition at line 113 of file Profiler.php.

114  {
115  \Magento\Framework\Profiler::start('cache_clean', $this->_getProfilerTags('clean'));
116  $result = parent::clean($mode, $tags);
117  \Magento\Framework\Profiler::stop('cache_clean');
118  return $result;
119  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

◆ load()

load (   $identifier)

{Load cache record by its unique identifier

Parameters
string$identifier
Returns
string|bool @api
}

Implements FrontendInterface.

Definition at line 78 of file Profiler.php.

79  {
80  \Magento\Framework\Profiler::start('cache_load', $this->_getProfilerTags('load'));
81  $result = parent::load($identifier);
82  \Magento\Framework\Profiler::stop('cache_load');
83  return $result;
84  }

◆ remove()

remove (   $identifier)

{Remove cache record by its unique identifier

Parameters
string$identifier
Returns
bool @api
}

Implements FrontendInterface.

Definition at line 102 of file Profiler.php.

103  {
104  \Magento\Framework\Profiler::start('cache_remove', $this->_getProfilerTags('remove'));
105  $result = parent::remove($identifier);
106  \Magento\Framework\Profiler::stop('cache_remove');
107  return $result;
108  }

◆ save()

save (   $data,
  $identifier,
array  $tags = [],
  $lifeTime = null 
)

Enforce marking with a tag

{Save cache record

Parameters
string$data
string$identifier
array$tags
int | bool | null$lifeTime
Returns
bool @api
}

Implements FrontendInterface.

Definition at line 91 of file Profiler.php.

92  {
93  \Magento\Framework\Profiler::start('cache_save', $this->_getProfilerTags('save'));
94  $result = parent::save($data, $identifier, $tags, $lifeTime);
95  \Magento\Framework\Profiler::stop('cache_save');
96  return $result;
97  }

◆ test()

test (   $identifier)

{Test if a cache is available for the given id

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

Implements FrontendInterface.

Definition at line 67 of file Profiler.php.

68  {
69  \Magento\Framework\Profiler::start('cache_test', $this->_getProfilerTags('test'));
70  $result = parent::test($identifier);
71  \Magento\Framework\Profiler::stop('cache_test');
72  return $result;
73  }

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