.

CacheXCache12Impl Class Reference
[XCache]

Cache Persistance using XCache 1.2. More...

Inheritance diagram for CacheXCache12Impl:
CacheXCacheImpl ICachePersister

List of all members.

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_keys_namespaces ($cache_keys)
  Return array of namespaces for keys.
  get_namespace_value ($ns)
  Get value of namespace counter.

Detailed Description

Cache Persistance using XCache 1.2.

Author:
Gerd Riesselmann

Definition at line 10 of file cache.xcache12.impl.php.


Member Function Documentation

CacheXCache12Impl::do_clear ( cache_keys  )  [protected]

Clear cache for given cache key(s).

Reimplemented from CacheXCacheImpl.

Definition at line 21 of file cache.xcache12.impl.php.

00021                                                  {
00022                 // We have do do a clear on 
00023                 // - App Key
00024                 // - Cache Keys
00025                 // - *
00026                 // This means we increment namespace of last key
00027                 // But first, strip of empty keys from the end of the array
00028                 $cleaned = $this->preprocess_keys($cache_keys, false);
00029                 $ns = $this->get_keys_namespaces($cleaned);
00030                 $n = array_pop($ns);
00031                 if ($n) {
00032                         // See http://code.google.com/p/memcached/wiki/FAQ#Deleting%5Fby%5FNamespace
00033                         // for how this trick works
00034                         xcache_inc($n, 1);
00035                 }
00036         }
CacheXCache12Impl::do_clear_all (  )  [protected]

Clear all cache.

Reimplemented from CacheXCacheImpl.

Definition at line 14 of file cache.xcache12.impl.php.

00014                                           {
00015                 $this->do_clear(array());
00016         }
CacheXCache12Impl::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 from CacheXCacheImpl.

Definition at line 43 of file cache.xcache12.impl.php.

00043                                                      {
00044                 $cache_keys = $this->preprocess_keys($cache_keys);
00045                 $ns_keys = $this->get_keys_namespaces($cache_keys);
00046                 
00047                 $tmp = array();
00048                 foreach($cache_keys as $key) {
00049                         $tmp[] = $key . ':=' . $this->get_namespace_value(array_shift($ns_keys));
00050                 }
00051                 
00052                 return implode('_', $tmp);              
00053         }
CacheXCache12Impl::get_keys_namespaces ( cache_keys  )  [protected]

Return array of namespaces for keys.

See http://code.google.com/p/memcached/wiki/FAQ#Deleting%5Fby%5FNamespace

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

Definition at line 63 of file cache.xcache12.impl.php.

00063                                                             {
00064                 $ret = array();
00065                 foreach(Arr::force($cache_keys, true) as $key) {
00066                         $ns_key .= 'g$ns' . $key;
00067                         $ret[] = $ns_key;
00068                 }
00069                 return $ret;
00070         }
CacheXCache12Impl::get_namespace_value ( ns  )  [protected]

Get value of namespace counter.

Parameters:
string  $ns Namespace

Definition at line 77 of file cache.xcache12.impl.php.

00077                                                     {
00078                 if (xcache_isset($ns)) {
00079                         $ret = xcache_get($ns);
00080                 }
00081                 else {
00082                         // This should be a transacton
00083                         $ret = rand(1, 1000);
00084                         xcache_set($ns, $ret);          
00085                 }
00086                 return $ret;
00087         }       

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