lithium\storage\cache\adapter\XCache::delete PHP Method

delete() public method

Note that this is not an atomic operation when using multiple keys.
public delete ( array $keys ) : boolean
$keys array Keys to uniquely identify the cached items.
return boolean `true` on successful delete, `false` otherwise.
    public function delete(array $keys)
    {
        if ($this->_config['scope']) {
            $keys = $this->_addScopePrefix($this->_config['scope'], $keys);
        }
        foreach ($keys as $key) {
            if (!xcache_unset($key)) {
                return false;
            }
        }
        return true;
    }

Usage Example

Beispiel #1
0
 public function testDeleteWithScope()
 {
     $adapter = new XCache(array('scope' => 'primary'));
     xcache_set('primary:key1', 'test1', 60);
     xcache_set('key1', 'test2', 60);
     $keys = array('key1');
     $expected = array('key1' => 'test1');
     $result = $adapter->delete($keys);
     $this->assertEqual($expected, $result);
     $result = xcache_isset('key1');
     $this->assertTrue($result);
     $result = xcache_isset('primary:key1');
     $this->assertFalse($result);
 }