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

Public Member Functions

 __construct (Array $parameters=[])
 
 store ($data)
 
 load ()
 
 clean ($lifetime=Cache::CLEAN_USER)
 
 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 .

Alternative PHP Cache backend manager. APC is a PECL extension, so it's not installed in PHP. Take care that APC module is loaded.

Definition at line 51 of file Apc.php.

Constructor & Destructor Documentation

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

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

Parameters
array$parametersParameters.
Returns
void
Exceptions

Definition at line 60 of file Apc.php.

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

Member Function Documentation

Hoa\Cache\Backend\Apc::clean (   $lifetime = Cache::CLEAN_USER)

Clean expired cache. Note : ::CLEAN_EXPIRED is not supported with APC.

Parameters
int$lifetimeLifetime of caches.
Returns
void
Exceptions

Definition at line 121 of file Apc.php.

122  {
123  switch ($lifetime) {
124  case Cache::CLEAN_ALL:
125  return apc_clear_cache();
126 
128  throw new Cache\Exception(
129  '\Hoa\Cache::CLEAN_EXPIRED constant is not supported by ' .
130  'APC cache backend.',
131  1
132  );
133 
134  case Cache::CLEAN_USER:
135  default:
136  return apc_clear_cache('user');
137  }
138 
139  return;
140  }
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\Apc::load ( )

Load data from APC cache.

Returns
void

Definition at line 100 of file Apc.php.

101  {
102  $this->clean();
103 
104  $content = apc_fetch($this->getIdMd5());
105 
106  if (true === $this->_parameters->getParameter('serialize_content')) {
107  $content = unserialize($content);
108  }
109 
110  return $content;
111  }
clean($lifetime=Cache::CLEAN_USER)
Definition: Apc.php:121
$content
Definition: Hoa.php:119

Here is the call graph for this function:

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

Remove a cache data.

Returns
void

Definition at line 147 of file Apc.php.

148  {
149  apc_delete($this->getIdMd5());
150 
151  return;
152  }

Here is the call graph for this function:

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

Save cache content in APC store.

Parameters
mixed$dataData to store.
Returns
mixed

Definition at line 80 of file Apc.php.

81  {
82  $this->clean();
83 
84  if (false !== $this->_parameters->getParameter('serialize_content')) {
85  $data = serialize($data);
86  }
87 
88  return apc_store(
89  $this->getIdMd5(),
90  $data,
91  $this->_parameters->getParameter('lifetime')
92  );
93  }
clean($lifetime=Cache::CLEAN_USER)
Definition: Apc.php:121

Here is the call graph for this function:


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