Hoa central
Public Member Functions | Public Attributes | List of all members
Hoa\Cache\Backend\ZendPlatform Class Reference
Inheritance diagram for Hoa\Cache\Backend\ZendPlatform:

Public Member Functions

 __construct (Array $parameters=[])
 
 store ($data)
 
 load ()
 
 clean ($lifetime=Cache::CLEAN_EXPIRED)
 
 remove ()
 
- Public Member Functions inherited from Hoa\Cache\Backend\Backend
 store ($data)
 
 load ()
 
 clean ($lifetime=Cache::CLEAN_EXPIRED)
 
 remove ()
 
- Public Member Functions inherited from Hoa\Cache\Cache
 __construct (Array $parameters=[])
 
 getParameters ()
 
 ksort (Array &$array)
 

Public Attributes

const INTERNAL_ZP_PREFIX = 'internal\ZPtag:'
 
- Public Attributes inherited from Hoa\Cache\Cache
const CLEAN_ALL = -1
 
const CLEAN_EXPIRED = 0
 
const CLEAN_USER = 1
 

Additional Inherited Members

- Protected Member Functions inherited from Hoa\Cache\Cache
 makeId ($id=null)
 
 setId ($id)
 
 getId ()
 
 getIdMd5 ()
 
 removeId ()
 
- Static Protected Attributes inherited from Hoa\Cache\Cache
static $_id = []
 

Detailed Description

Class .

ZendPlatform backend manager (yes yes, Zend :-)). Inspiration from Zend class for making this class.

Todo:
Need to be tested. I do not have the Zend Platform, I cannot make the test myself.

Definition at line 53 of file ZendPlatform.php.

Constructor & Destructor Documentation

Hoa\Cache\Backend\ZendPlatform::__construct ( Array  $parameters = [])

Validate that the Zend Platform is loaded and licensed.

Parameters
array$parametersParameters.
Returns
void
Exceptions

Definition at line 71 of file ZendPlatform.php.

72  {
73  if (!function_exists('accelerator_license_info')) {
74  throw new Cache\Exception(
75  'The Zend Platform extension must be loaded to use this backend.',
76  0
77  );
78  }
79 
80  if (!function_exists('accelerator_get_configuration')) {
81  $licenseInfos = accelerator_license_info();
82  throw new Cache\Exception(
83  'The Zend Platform extension is not loaded correctly: %s.',
84  1,
85  $licenseInfos['failure_reason']
86  );
87  }
88 
89  $configurations = accelerator_get_configuration();
90 
91  if (@!$configurations['output_cache_licensed']) {
92  throw new Cache\Exception(
93  'The Zend Platform extension does not have the proper license ' .
94  'to use content caching features.',
95  2
96  );
97  }
98 
99  if (@!$configurations['output_cache_enabled']) {
100  throw new Cache\Exception(
101  'The Zend Platform content caching feature must be enabled to ' .
102  'use this backend, set the ' .
103  'zend_accelerator.output_cache_enabled directive to on.',
104  3
105  );
106  }
107 
108  if (!is_writable($configuration['output_cache_dir'])) {
109  throw new Cache\Exception(
110  'The cache copies directory %s must be writable.',
111  4,
112  $configuration['output_cache_dir']
113  );
114  }
115 
116  parent::__construct($parameters);
117 
118  return;
119  }

Member Function Documentation

Hoa\Cache\Backend\ZendPlatform::clean (   $lifetime = Cache::CLEAN_EXPIRED)

Clean expired cache files. Note : ::CLEAN_USER is not supported, it's reserved for APC backend.

Parameters
string$lifetimeLifetime of caches.
Returns
void
Exceptions

Definition at line 170 of file ZendPlatform.php.

171  {
172  switch ($lifetime) {
173  case Cache::CLEAN_ALL:
174  break;
175 
177  $lifetime = $this->_parameters->getParameter('lifetime');
178 
179  break;
180 
181  case Cache::CLEAN_USER:
182  throw new \Hoa\Cache\Exception(
183  '\Hoa\Cache::CLEAN_USER constant is not supported by ' .
184  'ZendPlatform cache backend.',
185  3
186  );
187 
188  break;
189 
190  default:
191  $lifetime = $lifetime;
192  }
193 
194  $directory =
195  ini_get('zend_accelerator.output_cache_dir') . DS .
196  '.php_cache_api';
197 
198  try {
199  $finder = new HoaFile\Finder();
200  $finder
201  ->in($directory)
202  ->files()
203  ->modified('since ' . $lifetime . ' seconds');
204 
205  foreach ($finder as $file) {
206  $file->open()->delete();
207  $file->close();
208  }
209  } catch (File\Exception\FileDoesNotExist $e) {
210  }
211 
212  return;
213  }
const CLEAN_EXPIRED
Definition: Cache.php:62
const CLEAN_ALL
Definition: Cache.php:55
const CLEAN_USER
Definition: Cache.php:69

Here is the caller graph for this function:

Hoa\Cache\Backend\ZendPlatform::load ( )

Load a cache file.

Returns
mixed

Definition at line 145 of file ZendPlatform.php.

146  {
147  $this->clean();
148 
149  $content = output_cache_get(
150  $this->getIdMd5(),
151  $this->_parameters->getParameter('lifetime')
152  );
153 
154  if (isset($return[0])) {
155  return $return[0];
156  }
157 
158  return false;
159  }
clean($lifetime=Cache::CLEAN_EXPIRED)
$content
Definition: Hoa.php:119

Here is the call graph for this function:

Hoa\Cache\Backend\ZendPlatform::remove ( )

Remove a cache file.

Returns
void

Definition at line 220 of file ZendPlatform.php.

221  {
222  output_cache_remove_key($this->getIdMd5());
223 
224  return;
225  }

Here is the call graph for this function:

Hoa\Cache\Backend\ZendPlatform::store (   $data)

Save cache content into the ZendPlatform storage. Data is already serialized.

Parameters
string$dataData to store.
Returns
void

Definition at line 128 of file ZendPlatform.php.

129  {
130  $this->clean();
131 
132  output_cache_put(
133  $this->getIdMd5(),
134  [$data, time()]
135  );
136 
137  return;
138  }
clean($lifetime=Cache::CLEAN_EXPIRED)

Here is the call graph for this function:

Member Data Documentation

const Hoa\Cache\Backend\ZendPlatform::INTERNAL_ZP_PREFIX = 'internal\ZPtag:'

Internal ZendPlatform prefix.

string

Definition at line 60 of file ZendPlatform.php.


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