.

CacheXCacheImpl Class Reference
[XCache]

Cache Persistance using XCache. More...

Inheritance diagram for CacheXCacheImpl:
ICachePersister CacheXCache12Impl CacheXCache13Impl

List of all members.

Public Member Functions

  clear ($cache_keys=NULL)
  Clear the cache.
  is_cached ($cache_keys)
  Returns true, if item is chaced.
  read ($cache_keys)
  Read from cache.
  remove_expired ()
  Removes expired cache entries.
  store ($cache_keys, $content, $cache_life_time, $data= '', $is_compressed=false)
  Store content in cache.

Protected Member Functions

  do_clear ($cache_keys)
  Clear cache for given cache key(s).
  do_clear_all ()
  Clear all cache.
  flatten_keys ($cache_keys)
  Transform the given param into a key string.
  get_app_key ()
  Return key to make the current app unique.
  preprocess_keys ($cache_keys, $strip_empty=true)
  Strip empty keys from end of $cache_keys.

Detailed Description

Cache Persistance using XCache.

Author:
Gerd Riesselmann

Definition at line 81 of file cache.xcache.impl.php.


Member Function Documentation

CacheXCacheImpl::clear ( cache_keys = NULL  ) 

Clear the cache.

Parameters:
Mixed  A set of key params, may be an array or a string, or an ICachable instance. If NULL, all is cleared

Implements ICachePersister.

Definition at line 132 of file cache.xcache.impl.php.

00132                                                   {
00133                 if (empty($cache_keys)) {
00134                         $this->do_clear_all();
00135                 }
00136                 else {
00137                         $this->do_clear($cache_keys);
00138                 }
00139         }
CacheXCacheImpl::do_clear ( cache_keys  )  [protected]

Clear cache for given cache key(s).

Reimplemented in CacheXCache12Impl.

Definition at line 151 of file cache.xcache.impl.php.

00151                                                  {
00152                 $key = $this->flatten_keys($cache_keys);
00153                 xcache_unset($key);
00154                 xcache_unset_by_prefix($key . '_g$c');
00155         }
CacheXCacheImpl::do_clear_all (  )  [protected]

Clear all cache.

Reimplemented in CacheXCache12Impl.

Definition at line 144 of file cache.xcache.impl.php.

00144                                           {
00145                 xcache_unset_by_prefix($this->get_app_key());
00146         }
CacheXCacheImpl::flatten_keys ( cache_keys  )  [protected]

Transform the given param into a key string.

Parameters:
Mixed  A set of key params, may be an array or a string

Reimplemented in CacheXCache12Impl.

Definition at line 192 of file cache.xcache.impl.php.

00192                                                      {
00193                 $cache_keys = $this->preprocess_keys($cache_keys);
00194                 $ret .= implode('_g$c', $cache_keys);
00195                 return $ret;            
00196         }
CacheXCacheImpl::get_app_key (  )  [protected]

Return key to make the current app unique.

Returns:
string

Definition at line 162 of file cache.xcache.impl.php.

00162                                          {
00163                 return 'g$c' . Config::get_url(Config::URL_DOMAIN) . '';
00164         }
CacheXCacheImpl::is_cached ( cache_keys  ) 

Returns true, if item is chaced.

Implements ICachePersister.

Definition at line 85 of file cache.xcache.impl.php.

00085                                                {
00086                 $key = $this->flatten_keys($cache_keys);
00087                 return xcache_isset($key);
00088         }
CacheXCacheImpl::preprocess_keys ( cache_keys,
strip_empty = true  
) [protected]

Strip empty keys from end of $cache_keys.

Definition at line 169 of file cache.xcache.impl.php.

00169                                                                              {
00170                 $cleaned = array($this->get_app_key());
00171                 if ($strip_empty) {
00172                         foreach(Arr::force($cache_keys, false) as $key) {
00173                                 if ($key || $key == '0') {
00174                                         $cleaned[] = $key;
00175                                 } 
00176                                 else {
00177                                         break;
00178                                 }
00179                         }               
00180                 }
00181                 else {
00182                         $cleaned = array_merge($cleaned, Arr::force($cache_keys, true));
00183                 }
00184                 return $cleaned;
00185         }
CacheXCacheImpl::read ( cache_keys  ) 

Read from cache.

Parameters:
Mixed  A set of key params, may be an array or a string
Returns:
ICacheItem The cache as array with members "content" and "data", false if cache is not found

Implements ICachePersister.

Definition at line 96 of file cache.xcache.impl.php.

00096                                           {
00097                 $ret = false;
00098                 $key = $this->flatten_keys($cache_keys);
00099                 if (xcache_isset($key)) {
00100                         $ret = new XCacheCacheItem(xcache_get($key));
00101                 }
00102                 return $ret;
00103         }
CacheXCacheImpl::remove_expired (  ) 

Removes expired cache entries.

Implements ICachePersister.

Definition at line 201 of file cache.xcache.impl.php.

00201                                          {
00202                 // Nothing to do, xcache does this for us
00203         }
CacheXCacheImpl::store ( cache_keys,
content,
cache_life_time,
data = '',
is_compressed = false  
)

Store content in cache.

Parameters:
Mixed  A set of key params, may be an array or a string
string  The cache

Implements ICachePersister.

Definition at line 111 of file cache.xcache.impl.php.

00111                                                                                                            {
00112                 if (!$is_compressed) {
00113                         if (function_exists('gzdeflate')) {
00114                                 $content = gzdeflate($content, 9);
00115                         }
00116                 } 
00117                 $data = array(
00118                         'content' => $content,
00119                         'data' => $data,
00120                         'creationdate' => time(),
00121                         'expirationdate' => time() + $cache_life_time                   
00122                 );
00123                 $key = $this->flatten_keys($cache_keys);
00124                 xcache_set($key, $data, $cache_life_time);
00125         }

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