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

delete() public method

Will attempt to remove specified keys from the user space cache.
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 (count($keys) > 1) {
            return $this->connection->deleteMulti($keys);
        }
        return $this->connection->delete(current($keys));
    }

Usage Example

示例#1
0
 public function testDeleteWithScope()
 {
     $adapter = new Memcache(array('scope' => 'primary'));
     $this->_conn->set('primary:key1', 'test1', 60);
     $this->_conn->set('key1', 'test2', 60);
     $keys = array('key1');
     $expected = array('key1' => 'test1');
     $adapter->delete($keys);
     $result = (bool) $this->_conn->get('key1');
     $this->assertTrue($result);
     $result = $this->_conn->get('primary:key1');
     $this->assertFalse($result);
 }