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

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 .

Xcache manager. XCache is an extension, take care that XCache is loaded.

Definition at line 50 of file Xcache.php.

Constructor & Destructor Documentation

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

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

Parameters
array$parametersParameters.
Returns
void
Exceptions

Definition at line 59 of file Xcache.php.

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

Member Function Documentation

Hoa\Cache\Backend\Xcache::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 124 of file Xcache.php.

125  {
126  switch ($lifetime) {
127  case Cache::CLEAN_ALL:
128  for ($i = 0, $n = xcache_count(XC_TYPE_VAR); $i < $n; $i++) {
129  if (false !== xcache_clear_cache(XC_TYPE_VAR, $i)) {
130  throw new Cache\Exception(
131  'Clear all cache of XCache failed ' .
132  '(maybe for the cache number %s).',
133  1,
134  $i
135  );
136  }
137  }
138 
139  break;
140 
142  // Manage by XCache.
143  break;
144 
145  case Cache::CLEAN_USER:
146  throw new Cache\Exception(
147  '\Hoa\Cache::CLEAN_USER constant is not supported by ' .
148  'XCache backend.',
149  2
150  );
151  }
152 
153  return;
154  }
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\Xcache::load ( )

Load data from XCache cache.

Returns
mixed

Definition at line 102 of file Xcache.php.

103  {
104  $this->clean();
105 
106  $content = xcache_get($this->getIdMd5());
107 
108  if (true === $this->_parameters->getParameter('serialize_content')) {
109  $content = unserialize($content);
110  }
111 
112  return $content;
113  }
clean($lifetime=Cache::CLEAN_EXPIRED)
Definition: Xcache.php:124
$content
Definition: Hoa.php:119

Here is the call graph for this function:

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

Remove a cache data.

Returns
void
Exceptions

Definition at line 162 of file Xcache.php.

163  {
164  xcache_clear_cache(XC_TYPE_VAR, $this->getId());
165 
166  return;
167  }

Here is the call graph for this function:

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

Save cache content in XCache store.

Parameters
string$dataData to store.
Returns
void
Exceptions

Definition at line 80 of file Xcache.php.

81  {
82  $this->clean();
83 
84  if (true === $this->_parameters->getParameter('serialize_content')) {
85  $data = serialize($data);
86  }
87 
88  xcache_set(
89  $this->getIdMd5(),
90  $data,
91  $this->_parameters->getParameter('lifetime')
92  );
93 
94  return;
95  }
clean($lifetime=Cache::CLEAN_EXPIRED)
Definition: Xcache.php:124

Here is the call graph for this function:


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