The XCache adapter is meant to be used through the Cache interface, which abstracts away key generation, adapter instantiation and filter implementation. A simple configuration of this adapter can be accomplished in app/config/bootstrap/cache.php as follows: {{{ use lithium\storage\Cache; Cache::config(array( 'cache-config-name' => array( 'adapter' => 'XCache', 'username' => 'user', 'password' => 'pass' ) )); }}} Note that the username and password configuration fields are only required if you wish to use XCache::clear() - all other methods do not require XCache administrator credentials. This XCache adapter provides basic support for write, read, delete and clear cache functionality, as well as allowing the first four methods to be filtered as per the Lithium filtering system. This adapter does *not* allow multi-key operations for any methods.
See also: lithium\storage\Cache::key()
See also: lithium\storage\cache\adapter
Inheritance: extends lithium\core\Object
Exemple #1
0
 public function testWriteDefaultCacheExpiry()
 {
     $XCache = new XCache(array('expiry' => '+5 seconds'));
     $key = 'default_key';
     $data = 'value';
     $time = strtotime('+5 seconds');
     $closure = $XCache->write($key, $data);
     $this->assertTrue(is_callable($closure));
     $params = compact('key', 'data');
     $result = $closure($XCache, $params, null);
     $expected = $data;
     $this->assertEqual($expected, $result);
     $result = xcache_get($key);
     $this->assertEqual($expected, $result);
     $result = xcache_unset($key);
     $this->assertTrue($result);
 }
Exemple #2
0
 public function testIncrementWithScope()
 {
     $adapter = new XCache(array('scope' => 'primary'));
     xcache_set('primary:key1', 1, 60);
     xcache_set('key1', 1, 60);
     $adapter->increment('key1');
     $expected = 1;
     $result = xcache_get('key1');
     $this->assertEqual($expected, $result);
     $expected = 2;
     $result = xcache_get('primary:key1');
     $this->assertEqual($expected, $result);
 }