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

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)
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Cache\Cache
const CLEAN_ALL = -1
 
const CLEAN_EXPIRED = 0
 
const CLEAN_USER = 1
 
- 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 .

Eaccelerator backend manager. EAccelerator is an extension, take care that EAccelerator is loaded.

Definition at line 50 of file Eaccelerator.php.

Constructor & Destructor Documentation

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

Check if EAccelerator is loaded, else an exception is thrown.

Parameters
array$parametersParameters.
Returns
void
Exceptions

Definition at line 59 of file Eaccelerator.php.

60  {
61  if (!extension_loaded('eaccelerator')) {
62  throw new Cache\Exception(
63  'EAccelerator is not loaded on server.',
64  0
65  );
66  }
67 
68  parent::__construct($parameters);
69 
70  return;
71  }

Member Function Documentation

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

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

Parameters
int$lifetimeLifetime of caches.
Returns
void
Exceptions

Definition at line 115 of file Eaccelerator.php.

116  {
117  switch ($lifetime) {
118  case Cache::CLEAN_ALL:
119  $infos = eaccelerator_list_keys();
120 
121  // EAccelerator bug (http://eaccelerator.net/ticket/287).
122  foreach ($infos as $foo => $info) {
123  $key =
124  0 === strpos($info['name'], ':')
125  ? substr($info['name'], 1)
126  : $info['name'];
127 
128  if (false === eaccelerator_rm($key)) {
129  throw new \Hoa\Cache\Exception(
130  'Remove all existing cache file failed ' .
131  '(maybe for the %s cache).',
132  1,
133  $key
134  );
135  }
136  }
137 
138  break;
139 
141  // Manage by EAccelerator.
142  break;
143 
144  case Cache::CLEAN_USER:
145  throw new \Hoa\Cache\Exception(
146  '\Hoa\Cache::CLEAN_USER constant is not supported by ' .
147  'EAccelerator backend.',
148  2
149  );
150  }
151 
152  return;
153  }
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\Eaccelerator::load ( )

Load data from EAccelerator cache. Data is obligatory unseralized, please see the self::save() method.

Returns
void

Definition at line 97 of file Eaccelerator.php.

98  {
99  $this->clean();
100 
101  $content = eaccelerator_get($this->getIdMd5());
102 
103  return unserialize($content);
104  }
clean($lifetime=Cache::CLEAN_EXPIRED)
$content
Definition: Hoa.php:119

Here is the call graph for this function:

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

Remove a cache data.

Returns
void

Definition at line 160 of file Eaccelerator.php.

161  {
162  eaccelerator_rm($this->getIdMd5());
163 
164  return;
165  }

Here is the call graph for this function:

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

Save cache content in EAccelerator store. All data is obligatory serialized.

Parameters
mixed$dataData to store.
Returns
void

Definition at line 80 of file Eaccelerator.php.

81  {
82  $this->clean();
83 
84  return eaccelerator_put(
85  $this->getIdMd5(),
86  serialize($data),
87  $this->_parameters->getParameter('lifetime')
88  );
89  }
clean($lifetime=Cache::CLEAN_EXPIRED)

Here is the call graph for this function:


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