Hoa central
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Attributes | Private Attributes | List of all members
Hoa\Cache\Cache Class Reference
Inheritance diagram for Hoa\Cache\Cache:

Public Member Functions

 __construct (Array $parameters=[])
 
 getParameters ()
 
 ksort (Array &$array)
 

Public Attributes

const CLEAN_ALL = -1
 
const CLEAN_EXPIRED = 0
 
const CLEAN_USER = 1
 

Protected Member Functions

 makeId ($id=null)
 
 setId ($id)
 
 getId ()
 
 getIdMd5 ()
 
 removeId ()
 

Static Protected Attributes

static $_id = []
 

Private Attributes

 $_parameters = null
 

Detailed Description

Class .

Definition at line 48 of file Cache.php.

Constructor & Destructor Documentation

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

Constructor.

Parameters
array$parametersParameters.
Returns
void

Example with a SQLite database loaded in memory:

'sqlite.cache_directory' => ':memory:',

Definition at line 93 of file Cache.php.

94  {
95  $this->_parameters = new Core\Parameter(
96  __CLASS__,
97  [
98  'id' => null
99  ],
100  [
101  'lifetime' => 3600,
102  'serialize_content' => true,
103  'make_id_with.cookie' => true,
104  'make_id_with.files' => true,
105  'make_id_with.get' => true,
106  'make_id_with.post' => true,
107  'make_id_with.server' => false,
108  'make_id_with.session' => true,
109 
110  'apc' => '',
111 
112  'eaccelerator' => '',
113 
114  'file.cache_directory' => 'hoa://Data/Variable/Cache/(:id:).ca',
115  'file.compress.active' => true,
116  'file.compress.level' => true,
117 
118  'memcache.compress.active' => true,
119  'memcache.database.host' => '127.0.0.1',
120  'memcache.database.port' => 11211,
121  'memcache.database.persistent' => true,
122 
123  'sqlite.cache_directory' => 'hoa://Data/Variable/Cache/Cache.db',
129  'sqlite.database.host' => '127.0.0.1',
130 
131  'xcache' => '',
132 
133  'zendplatform' => ''
134  ]
135  );
136 
137  $this->_parameters->setParameters($parameters);
138 
139  return;
140  }

Member Function Documentation

Hoa\Cache\Cache::getId ( )
protected

Get last ID.

Returns
string
Exceptions

Definition at line 219 of file Cache.php.

220  {
221  end(self::$_id);
222 
223  return key(self::$_id);
224  }

Here is the caller graph for this function:

Hoa\Cache\Cache::getIdMd5 ( )
protected

Get last ID in MD5 format.

Returns
string
Exceptions

Definition at line 232 of file Cache.php.

233  {
234  end(self::$_id);
235 
236  return current(self::$_id);
237  }

Here is the caller graph for this function:

Hoa\Cache\Cache::getParameters ( )

Get parameters.

Returns

Implements Hoa\Core\Parameter\Parameterizable.

Definition at line 147 of file Cache.php.

148  {
149  return $this->_parameters;
150  }
Hoa\Cache\Cache::ksort ( Array &  $array)

Sort array of arrays etc., according to keys, recursively.

Parameters
array$arrayArray to sort.
Returns
array

Definition at line 258 of file Cache.php.

259  {
260  ksort($array);
261  foreach ($array as $key => $value) {
262  if (is_array($value)) {
263  $array[$key] = $this->ksort($value);
264  }
265  }
266 
267  return $array;
268  }
ksort(Array &$array)
Definition: Cache.php:258

Here is the caller graph for this function:

Hoa\Cache\Cache::makeId (   $id = null)
protected

Make an ID according to frontend options. We privilage _makeId to built suffixe of ID. As an idenfier shoud be unique, we add environments variables values. In this way, the identifier represents the current state of application.

Parameters
string$idIdentifier.
Returns
string
Exceptions

Definition at line 162 of file Cache.php.

163  {
164  $_id = $id;
165 
166  if (true === $this->_parameters->getParameter('make_id_with.cookie') &&
167  isset($_COOKIE)) {
168  $_id .= serialize($this->ksort($_COOKIE));
169  }
170 
171  if (true === $this->_parameters->getParameter('make_id_with.files') &&
172  isset($_FILES)) {
173  $_id .= serialize($this->ksort($_FILES));
174  }
175 
176  if (true === $this->_parameters->getParameter('make_id_with.get') &&
177  isset($_GET)) {
178  $_id .= serialize($this->ksort($_GET));
179  }
180 
181  if (true === $this->_parameters->getParameter('make_id_with.post') &&
182  isset($_POST)) {
183  $_id .= serialize($this->ksort($_POST));
184  }
185 
186  if (true === $this->_parameters->getParameter('make_id_with.server') &&
187  isset($_SERVER)) {
188  $_id .= serialize($this->ksort($_SERVER));
189  }
190 
191  if (true === $this->_parameters->getParameter('make_id_with.session') &&
192  isset($_SESSION)) {
193  $_id .= serialize($this->ksort($_SESSION));
194  }
195 
196  return self::$_id[$id] = md5($id . $_id);
197  }
ksort(Array &$array)
Definition: Cache.php:258
static $_id
Definition: Cache.php:83

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Cache\Cache::removeId ( )
protected

Remove a couple of ID/ID_MD5. By default, the last ID is removed.

Returns
void

Definition at line 245 of file Cache.php.

246  {
247  unset(self::$_id[$this->getId()]);
248 
249  return;
250  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Cache\Cache::setId (   $id)
protected

Set the current ID.

Parameters
string$idID.
Returns
string

Definition at line 205 of file Cache.php.

206  {
207  $old = $this->_parameters->getKeyword('id');
208  $this->_parameters->setKeyword('id', $id);
209 
210  return $old;
211  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Cache\Cache::$_id = []
staticprotected

Definition at line 83 of file Cache.php.

Hoa\Cache\Cache::$_parameters = null
private

Definition at line 76 of file Cache.php.

const Hoa\Cache\Cache::CLEAN_ALL = -1

Clean all entries.

int

Definition at line 55 of file Cache.php.

const Hoa\Cache\Cache::CLEAN_EXPIRED = 0

Clean expired entries.

int

Definition at line 62 of file Cache.php.

const Hoa\Cache\Cache::CLEAN_USER = 1

Clean (only for the APC backend).

int

Definition at line 69 of file Cache.php.


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